apache - htaccess set cookie then use skip rule flag in same line -



apache - htaccess set cookie then use skip rule flag in same line -

i writing code redirects mobile verision of website unless cookie has been set.

there link on mobile site, "go desktop site". it's target desktop site variable, "noredirect=1".

the next code in root .htaccess file on desktop site. checks variable , sets cookie if exists, skips next rule.

# check if noredirect query string rewritecond %{query_string} (^|&)noredirect=1(&|$) # set cookie want remain on desktop site # , skip next rule # below mobile rule not redirect # (cookie cannot set , read in 1 request) rewriterule ^ - [co=mredir:1:%{http_host},s=1]

the skip flag not seem working. below code have few rewriteconds , 1 rewriterule:

# check create sure haven't set cookie before rewritecond %{http:cookie} !\smredir=1(;|$) rewritecond %{http_user_agent} "android|blackberry|iphone|ipod|iemobile|opera|mobile|palmos|webos|googlebot-mobile" [nc,or] rewritecond %{http:profile} !^$ rewritecond %{http_host} ^(?:www\.)?((?!www\.)[^.]+)\.([^.]+\.[^.]+)$ [nc] rewriterule ^$ http://m.%1.%2 [l,r]

is skip flag meant still work when next rule has conditions preceding it?

also, main question: syntax skip flag right , can done in same line 1 setting cookie?

i've tried these 2 combinations:

rewriterule ^ - [co=mredir:1:%{http_host},s=1]

and

rewriterule ^ - [co=mredir:1:%{http_host}] [s=1]

neither give errors skip flag still not work.

help appreciated, thanks.

see tips debugging .htaccess rewrite rules general tips on how chop problem. need differentiate response cookies (output) request cookies (input). co flag sets response cookie, isn't visible in %{http:cookie} on current pass. either utilize skip chain correctly or set environment variable , utilize because visible.

apache .htaccess mod-rewrite cookies url-rewriting

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -