Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
TRICKY: Apache RewriteCond help with mobile device redirection using .htaccess
Old 04-22-2010, 04:10 AM Exclamation TRICKY: Apache RewriteCond help with mobile device redirection using .htaccess
Junior Talker

Posts: 1
Name: Thomas
Trades: 0
I am redirecting a list of know mobile devices based on their USER AGENT string. I found the code, it works great... However, I want to be able to exclude a subfolder in the following scenario:

1. I have an .htaccess script that is parsing user agent string and redirecting to /mobile/
(So if someone on an iPhone goes to www.domain.com it will auto-redirect them to www.domain.com/mobile)

2. If someone from a mobile device goes to the following www.domain.com/xml/feed I want them to not be redirected (and only to that folder - all other folders are fair)

Here is the .htaccess I have compiled so far:
Code:
  RewriteCond %{REQUEST_URI} !^/mobile/.*$
  RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml+xml" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "teli|tim-|toshi|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
  RewriteRule ^(.*)$ /mobile/ [L,R=302]
I know it should be something simple like:

Code:
RewriteCond %{REQUEST_URI} !^/xml
But I am either getting all subfolders redirected to /mobile or an error with "too many redirects/loops/etc"

Help please!
thomas1r is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-23-2010, 12:46 PM Re: TRICKY: Apache RewriteCond help with mobile device redirection using .htaccess
Novice Talker

Posts: 5
Name: Jay Towly
Trades: 0
A very quick "cheat" would be to create a .htaccess in the guests folder with the content "<IfModule mod_rewrite.c> RewriteEngine off </IfModule>" That will turn off rewrite for the folder in question (and any subfolders)

Hope this helps!
abuhl is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to TRICKY: Apache RewriteCond help with mobile device redirection using .htaccess
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21016 seconds with 12 queries