Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Mobile .htaccess problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Sysode" data-source="post: 196854" data-attributes="member: 25453"><p>Okay, so the aim of this script is to redirect to a mobile site have made, if the user is using a mobile/smartphone etc. However, I get an error when on a mobile device. Any idea's what is wrong?</p><p> </p><p>The error I get on my Samsung galaxy II is "Found, document has been moved"</p><p>My bro gets, on his samsung galaxy III "Redirect loop"</p><p> </p><p>[CODE]RewriteEngine on</p><p>RewriteBase /</p><p># Check if this is the noredirect query string</p><p>RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)</p><p># Set a cookie, and skip the next rule</p><p>RewriteRule ^ - [CO=mredir:0:www.reecematthews.co.uk]</p><p> </p><p># Check if this looks like a mobile device</p><p># (You could add another [OR] to the second one and add in what you</p><p># had to check, but I believe most mobile devices should send at</p><p># least one of these headers)</p><p>RewriteCond %{HTTP:x-wap-profile} !^$ [OR]</p><p>RewriteCond %{HTTP:Profile} !^$ [OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]</p><p>RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]</p><p>RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]</p><p> </p><p> </p><p># Check if we're not already on the mobile site</p><p>RewriteCond %{HTTP_HOST} !^m\.</p><p> </p><p># Can not read and write cookie in same request, must duplicate condition</p><p>RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)</p><p> </p><p> </p><p># Check to make sure we haven't set the cookie before</p><p>RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]</p><p> </p><p> </p><p># Now redirect to the mobile site</p><p>RewriteRule ^ http://reecematthews.co.uk/mobile/ [R,L][/CODE]</p><p> </p><p> </p><p>Thanks in advance <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Sysode, post: 196854, member: 25453"] Okay, so the aim of this script is to redirect to a mobile site have made, if the user is using a mobile/smartphone etc. However, I get an error when on a mobile device. Any idea's what is wrong? The error I get on my Samsung galaxy II is "Found, document has been moved" My bro gets, on his samsung galaxy III "Redirect loop" [CODE]RewriteEngine on RewriteBase / # Check if this is the noredirect query string RewriteCond %{QUERY_STRING} (^|&)m=0(&|$) # Set a cookie, and skip the next rule RewriteRule ^ - [CO=mredir:0:www.reecematthews.co.uk] # Check if this looks like a mobile device # (You could add another [OR] to the second one and add in what you # had to check, but I believe most mobile devices should send at # least one of these headers) RewriteCond %{HTTP:x-wap-profile} !^$ [OR] RewriteCond %{HTTP:Profile} !^$ [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-|tosh|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] RewriteCond %{HTTP_USER_AGENT} !macintosh [NC] # Check if we're not already on the mobile site RewriteCond %{HTTP_HOST} !^m\. # Can not read and write cookie in same request, must duplicate condition RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) # Check to make sure we haven't set the cookie before RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC] # Now redirect to the mobile site RewriteRule ^ http://reecematthews.co.uk/mobile/ [R,L][/CODE] Thanks in advance :) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Mobile .htaccess problem
Top