OK, so I got this figured out, and thought I'd post it here for
posterity.

Rather than putting the cookie rule in a separate .htaccess file in
the demo directory, I put them both in the root:

RewriteCond %{HTTP_HOST} ^demo.example.com$
RewriteCond %{REQUEST_URI} !^/demo/
RewriteCond %{HTTP_COOKIE} phn_demo=([^;]+)
RewriteRule (.*) /demo/%1/$1 [L]

RewriteCond %{HTTP_HOST} ^demo.example.com$
RewriteCond %{REQUEST_URI} !^/demo/
RewriteRule (.*) /demo/$1

It works wonderfully. I just realized I should probably remove the $1
from the second rule, though, as I don't want them going anywhere or
getting 404s if they don't have a cookie. Damned cool voodo.

-- 
Alan Little
Holotech Enterprises

On Thursday, March 9, 2006, 8:31:50 AM, you wrote:


> Sorry if this has been asked before; I tried to find if there were
> searchable archives for this list, but couldn't find anything.

> I want to do a rewrite based on the value of a cookie. I have a rule in
> doc root for the domain, which directs it to the demo directory based on
> the third-level domain:

>   RewriteCond %{HTTP_HOST} ^demo.example.com$
>   RewriteCond %{REQUEST_URI} !^/demo/
>   RewriteRule (.*) /demo/$1

> This works fine. From there, I want to re-direct to a sub-directory with
> the same name as the value of the cookie phn_demo, if the cookie is
> set. I tried this:

>   RewriteCond %{HTTP_COOKIE} phn_demo=(.*)
>   RewriteRule (.*) /demo/%1/$1

> but get a 500 error, which strangely doesn't show up in the logs. If the
> cookie is not set, I don't get an error.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to