Reputation: 67
I use mobile redirection code:
HTACCESS MOBILE SITE REDIRECTION CODE
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (mobile|android|blackberry|brew|cldc|docomo|htc|j2me|micromax|lg|midp|mot|motorola|netfront|nokia|obigo|openweb|opera.mini|palm|psp|samsung|sanyo|sch|sonyericsson|symbian|symbos|teleca|up.browser|vodafone|wap|webos|windows.ce) [NC]
RewriteRule ^(.*)$ url1 [R=302,L]
With this code my entire site redirect the mobile visitors to url1.
So, I want to keep that redirection as is it, but to have different redirection for one or more specific urls from my site e.g. http://www.mysite.com/sample.htm
to redirect visitors to url2, while the rest of the site to redirect visitors to url1.
Thank you.
Upvotes: 2
Views: 103
Reputation: 786291
Use following code:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (mobile|android|blackberry|brew|cldc|docomo|htc|j2me|micromax|lg|midp|mot|motorola|netfront|nokia|obigo|openweb|opera.mini|palm|psp|samsung|sanyo|sch|sonyericsson|symbian|symbos|teleca|up.browser|vodafone|wap|webos|windows.ce) [NC]
RewriteRule ^ - [E=IS_MOBILE:1]
RewriteCond %{ENV:IS_MOBILE} 1
RewriteRule ^sample\.htm/?$ url2 [R=302,L,NC]
RewriteCond %{ENV:IS_MOBILE} 1
RewriteRule (?!^url2/?$)^.*$ url1 [R=302,L,NC]
Upvotes: 1