Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Web Design (WordPress, Joomla, etc.) Redirecting to mobile website

  • Redirecting to mobile website

    Posted by Mike Healey on July 9, 2008 at 7:52 pm

    Hey folks – Not sure this is the appropriate place to post. I’ve been trying to research this topic on the web and haven’t had much luck finding a workable solution.

    I have a site written/hosted in HTML and I’m trying to write code to allow handhelds, PDA’s and phones to be redirected to the mobile version of the site.

    Since the main site is not written in .asp or .php apparently I don’t have a lot of options. I’m told that using .htaccess it’s possible to redirect but that’s where I get lost.

    Right now, you have to access the mobile version of the site by going to http://www.yourdomain.com/mobile and that’s not good enough. I need some guidance to be able to redirect if possible.

    Any suggestions?

    Thanks!

    ~Mike~

    Abraham Chaffin replied 15 years, 5 months ago 10 Members · 13 Replies
  • 13 Replies
  • Curtis Thompson

    July 9, 2008 at 8:13 pm

    hello…

    ya – you can use http rewrite rules, or you could use javascript, but the latter might not be as feasible because if they have js disabled on the pda, it won’t catch. http rewrite happens on your server based on their user agent, though, so that would be much more reliable…

    that said, as you can see from this list:

    https://www.zytrax.com/tech/web/mobile_ids.html

    there are quite a few user agents out there in mobile land. here’s an example that finds iphone and itouch (as claimed by the author – by that i mean i’m not up on what the user agent is for these devices):

    https://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/

    basically you’ll have to expand on that (if your isp allows you to use .htaccess files or overwrite this type of control – a lot might not, so you’ll have to check with them)…what’s happening here is all in the rewrite condition and rule – so to take an example from another blog:

    RewriteCond %{HTTP_USER_AGENT} “Windows CE” [NC,OR] #Windows CE and Pocket PC
    RewriteCond %{HTTP_USER_AGENT} “NetFront” [NC,OR] #PalmSource WebBrowser 2.0
    RewriteCond %{HTTP_USER_AGENT} “Palm OS” [NC,OR] #Eudora Web Browser for Palm
    RewriteCond %{HTTP_USER_AGENT} “Blazer” [NC,OR] #Handspring Blazer Browser
    RewriteCond %{HTTP_USER_AGENT} “Elaine” [NC,OR] #RIM Devices
    RewriteCond %{HTTP_USER_AGENT} “^WAP.*$” [NC,OR] #WAP Browsers
    RewriteCond %{HTTP_USER_AGENT} “Plucker” [NC,OR] #Plucker Offline download client
    RewriteCond %{HTTP_USER_AGENT} “AvantGo” [NC] #AvantGo Service
    RewriteRule ^index\.php https://www.yourdomain.net/pda.php [L,R]

    basically if the browser’s user agent matches one of these strings, then the rewrite rule kicks in…

    it’s not the most basic of concepts and rewrite stuff can be quite touchy, so it could be tricky to implement, but that’s how you’d go about it…

    hope that helps a bit!

    sitruc

  • Mark Cookman

    October 30, 2008 at 5:55 pm

    Heh thanks Curtis – whenever I have a query it seems you have posted an answer on it!
    After finding (what I presume is your great work on) the mobi Cow site I am inspired to start “mobifying” my site too.
    regards
    Mark

  • Curtis Thompson

    October 30, 2008 at 6:04 pm

    hello…

    [mark cookman] “what I presume is your great work on”

    actually not mine…but glad you like the cow feature!

    always glad to help out when i can… 🙂

    sitruc

  • Mark Cookman

    October 31, 2008 at 12:41 pm

    (heh I just sussed sitruc ….) I spent the night reading about mobi sites but didn’t really get much hardcore XTML stuff.
    Im planning to start off from scratch with a redirect.php and a print hello world; page.
    may I ask you;

    Whats a good place to lurk around to pick up knowledge to create an iPhone/Blackberry friendly video delivery section of my site?

    I’m tempted to go for youtube (with all privacy settings on) but it seems such a cop out and there is probably a no commercial use blah in there somewhere.
    cheers
    M
    .

  • Don Manj

    November 17, 2008 at 1:14 am

    I work for a design agency and we use a web service to detect mobile devices when they hit our client sites.

    There are a few of them out there, but we have used handsetdetection.com most recently.

  • Barry Latimer

    February 6, 2009 at 6:08 am

    Hi,

    Detecting a mobile phone browsing your website these days isn’t that hard I have used a few different tools to do this

    Here is an example in PHP
    https://mobiforge.com/developing/story/lightweight-device-detection-php

    Or there is a site called mobile elements(https://www.mobileelements.com) that has a simple webservice that tells you in the browser is a mobile phone or not quite easily

  • Idel Fuschini

    March 26, 2009 at 6:55 pm

    Hi,
    I suggest to see this project call “Apache Mobile Filter”.

    Here where you can doanload the software: https://sourceforge.net/projects/mobilefilter/

    Here where you can see the documentation: https://www.idelfuschini.it/apache-mobile-filter.html

  • Idel Fuschini

    May 26, 2009 at 3:26 pm

    I have published the new version of Apache Mobile Filter, now the filter is give to you the information of capabilities as apache environment.
    Now you can develope in any language (php,jsp, ruby etc.) and have the information of mobile capability.

    Read more info here: https://www.idelfuschini.it/it/apache-mobile-filter-v2x.html

    Mobile Evangelist

  • Deshmukh David

    July 23, 2009 at 3:07 pm

    Best method of Redirecting your website to mobile website subdomain is shown on this link: https://www.deshmukhelectric.com/engineering
    The website also contains files which you can simply download and upload to your website with minor changes.

  • Mike Lynn

    July 21, 2010 at 8:56 am

    Here’s an article I wrote which describes in detail how to accomplish mobile browser device detection and redirection.
    Perl/CGI:
    https://www.mlynn.org/2010/07/mobile-device-detection-and-redirection-with-perl-and-cgi/
    PHP:
    https://www.mlynn.org/2010/06/mobile-device-detection-and-redirection-with-php/

    I tend to avoid javascript because of the device limitations. These examples will show you how to accomplish detection and redirection without javascript. The code for the examples is freely available at the web site:
    https://www.mlynn.org/wp-content/plugins/download-monitor/download.php?id=2

    Enjoy!

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy