Mobile website redirect - how?

10 replies
I've been reading up on mobile websites and it looks like you need to provide some sort of redirect script on the client's website. How easy is that to do? Has anyone had problems with a business who has a website built by an outside company and doesn't know the usernames or passwords to get in to make the change?

Also, does the redirect script (if I'm calling it the wrong thing I apologize) simply go at the beginning of the index.html or index.php file?

Thanks.

Mike
#mobile #redirect #website
  • Profile picture of the author Warrior Ben
    It's actually pretty simple if there is an .htaccess file. Just paste the following script in the .htaccess file and you'll be good.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_USER_AGENT} Android [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} iphone [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Windows\ CE [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} BlackBerry [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} NetFront [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Opera\ Mini [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} iemobile [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} webos [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Palm\ OS [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Blazer [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Elaine [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^WAP.*$ [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Plucker [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} AvantGo [NC]
    RewriteCond $1 !^mobile
    RewriteRule ^(.*)$ /mobile/$1 [L]
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    One thing to note is that this assumes the mobile website files are located on yourdomain.com/mobile/

    You can change this by changing the 6th line from the bottom.

    I hope this helps!

    -Ben
    {{ DiscussionBoard.errors[4673813].message }}
  • Profile picture of the author mjbmedia
    you realise a number of people (like me) are looking at that coding thinking WTF!!!!

    There needs to be a computer language translation device ;-)
    Signature

    Mike

    {{ DiscussionBoard.errors[4674259].message }}
    • Profile picture of the author LakiPolitis
      Originally Posted by mjbmedia View Post

      you realise a number of people (like me) are looking at that coding thinking WTF!!!!

      There needs to be a computer language translation device ;-)
      It's pretty simple, dude. And I use IIS and ASP.net not apache and PHP.

      ----------------------------------------------------------------
      RewriteCond %{HTTP_USER_AGENT} Android [NC,OR]
      ----------------------------------------------------------------
      If the user agent is an Android phone...

      ----------------------------------------------------------------
      RewriteCond $1 !^mobile
      RewriteRule ^(.*)$ /mobile/$1 [L]
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      ----------------------------------------------------------------
      Reroute them to the subdirectory mobile and then hit that index.php file.

      If you're website needs to display the same content, but in different positions, formats, etc. Use the mobile css stylesheet. You'll be able to modify quickly and easily.
      {{ DiscussionBoard.errors[4675674].message }}
      • Profile picture of the author mjbmedia
        Originally Posted by LakiPolitis View Post

        It's pretty simple, dude. And I use IIS and ASP.net not apache and PHP.

        ----------------------------------------------------------------
        RewriteCond %{HTTP_USER_AGENT} Android [NC,OR]
        ----------------------------------------------------------------
        If the user agent is an Android phone...

        ----------------------------------------------------------------
        RewriteCond $1 !^mobile
        RewriteRule ^(.*)$ /mobile/$1 [L]
        RewriteRule ^index.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        ----------------------------------------------------------------
        Reroute them to the subdirectory mobile and then hit that index.php file.

        If you're website needs to display the same content, but in different positions, formats, etc. Use the mobile css stylesheet. You'll be able to modify quickly and easily.
        OK see now that may be simple to you, but you aint speaking my language me old china.

        To be fair I dont really want to know cos I just outsource it , but thanks for trying
        Signature

        Mike

        {{ DiscussionBoard.errors[4676019].message }}
  • Profile picture of the author Jay Moreno
    there are also php versions and javascript variations that offer the same functionality and that may not look as scary! lol
    Signature
    Sorry, I am too busy helping people to think of a cool signature!
    {{ DiscussionBoard.errors[4675569].message }}
    • Profile picture of the author Pierre!
      So - You simply need a 'mobile' sub-directory - called 'm' or 'mobile' - and the script to define the phone and the location of the Mobile Site files...

      Do I have this right?

      I have read about the 'm.seeberconsulting.com' subdirectory and all kinds of other stuff... but just creating a mobile site directory and using the script works?

      Leave it to a computer guy to complicate things :p

      Patrick
      Signature
      Internet Safety Tips - The Essentials
      Internet Safety Tips – “The Essentials” – Examples Of Attacks
      Check out this chapter, then sign up to download YOUR copy!
      {{ DiscussionBoard.errors[4675613].message }}
  • Profile picture of the author ChristineCobb
    If you have a WordPress site, you can use a plugin like WP Touch.
    Signature
    Creating an Affiliate Tools Page Couldn't Get Any Easier. Find out how.

    Free Screencast Videos Resource Guide Here
    {{ DiscussionBoard.errors[4675699].message }}
    • Profile picture of the author Jay Moreno
      Originally Posted by chriscobb View Post

      If you have a WordPress site, you can use a plugin like WP Touch.
      @chriscobb - WP Touch doesnt redirect you to a specified mobile website - it just renders a mobile version of your wordpress blog.. that said it doesnt render a true mobile business website out of the box either ie it lacks click to call features, click for directions, mobile feedback form, etc, etc
      Signature
      Sorry, I am too busy helping people to think of a cool signature!
      {{ DiscussionBoard.errors[4675928].message }}

Trending Topics