Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule with HTTP USER AGENT and HTTP COOKIE conditions

         

ocon

2:02 pm on Jan 13, 2012 (gmt 0)

10+ Year Member Top Contributors Of The Month



I'm trying to redirect iPhone users going to my homepage to go to the mobile version unless they have a cookie to override that redirect. I'm close, but not quite there, and was hoping somebody might be able to help me identify what I'm doing wrong.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{HTTP_COOKIE} ^mobile=no$
RewriteRule ^$ /m/ [L]

lucy24

9:25 pm on Jan 13, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Users who make null requests (the home page without slash or "index.html") whose cookie contains the exact text "mobile=no" are served content from (not redirected to) the page whose exact name is /m/

:: peering into crystal ball ::

You have prior experience with mod_alias using Redirects by that name, and haven't quite got a grip on the difference in syntax.

Bookmark if you haven't already:

[httpd.apache.org...]

What, if anything, does the current rule do? I mean, what does it really do? You've been clear on what you want it to do, and that's a good start. (I'm not being satirical. A lot of people skip this first step.)