Jump to content

Recommended Posts

Need help with following rule. Crappy at mod-rewrite. Need to redirect users to a mobile version of a site if a mobile device is detected. The pages on both sites are identical, so if a user on an iPhone goes to www.foobar.com/test-123.php it will 301 redirect to mobile.foobar.com/test-123.php

 

So far:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(up.browser|up.link|windows\ ce|iPhone|Palm|BlackBerry|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp).*$ [NC]
RewriteRule ^(.*)$ http://www.foobar.com [R=301]

Obviously this just redirects to the root of the mobile domain. Need to redirect to the landing page.

Link to comment
https://forums.phpfreaks.com/topic/194786-redirect-for-mobile-devices/
Share on other sites

Never mind, I think this should work.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(up.browser|up.link|windows\ ce|iPhone|Palm|BlackBerry|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp).*$ [NC]
RewriteRule ^(.*)$ http://www.foobar.com%{REQUEST_URI} [R=301]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.