views:

190

answers:

1

I'm trying to catch all the non-logged-in users who are trying to get to a directory (where my .htaccess is placed). If someone is not logged-in and try to access some page in this directory, it will be redirected to page "user/?login=222" A user is logged-in, when the Cookie "HDV-UL" starts with a 5 digit number.

This is my .htaccess:

# Working with Apache 1.3
Options -Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !HDV-UL=[0-9]{5}-[^;]+;
RewriteRule .* /user/?login=222 [R,L]

This is not working, any clues?

+1  A: 

Try this rule:

RewriteCond %{HTTP_COOKIE} !HDV-UL=[0-9]{5}-[^;]+
RewriteRule !^user/$ /user/?login=222 [R,L]

I removed the trailing ; as it’s only present if there are multiple cookies and I excluded the target of the redirect to avoid a redirection loop.

Gumbo