.htaccess - 'View Full Site' add ?m=0 to all inside pages -


rewriterule ^(.*)\.php$ ^(.*)\.php$?m=0 [r=301,l] 

i want inside pages rewritten ?m=0 coming sitedotcom?m=0

so if lands comes full site using trailing ? want links ?m=0

??

reason: mobile redirect full site button works once. not work if user clicks on something. returns mobile site.

my code looks this

rewriteengine on rewritebase /  # check if mobile=1 set , set cookie 'mobile' equal 1 rewritecond %{query_string} (^|&)mobile=1(&|$) rewriterule ^ - [co=mobile:1:%{http_host}]  # check if mobile=0 set , set cookie 'mobile' equal 0 rewritecond %{query_string} (^|&)mobile=0(&|$) rewriterule ^ - [co=mobile:0:%{http_host}]  # cookie can't set , read in same request check rewritecond %{query_string} (^|&)mobile=0(&|$) rewriterule ^ - [s=1]  # check if looks mobile device rewritecond %{http:x-wap-profile} !^$ [or] rewritecond %{http_user_agent} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [nc,or] rewritecond %{http:profile}       !^$  # check if we're not on mobile site rewritecond %{http_host}          !^m\. # check make sure haven't set cookie before rewritecond %{http:cookie}        !\mobile=0(;|$) # redirect mobile site rewriterule ^ http://m.site.com%{request_uri} [r,l]     

tried top code return infinite loop.? thoughts?

this line here:

rewritecond %{http:cookie}        !\mobile=0(;|$) 

should checking query string instead well:

rewritecond %{query_string}       !(^|&)mobile=0(&|$) 

because cookie isn't sent browser until server responds, time redirect made. 2 co lines creates cookie sent browser, , redirect them mobile before there's response.


how this? change redirect rule to:

rewritecond %{http:cookie}        mobile=1(;|$) rewritecond %{query_string}       ^$ rewriterule ^ http://m.site.com%{request_uri}?mobile=1 [r,l]  rewritecond %{http:cookie}        \mobile=0(;|$) rewritecond %{query_string}       ^$ rewriterule ^ http://site.com%{request_uri}?mobile=0 [r,l] 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -