views:

13

answers:

2

Hi.. this might be a no brainer to some, but I am trying to specify some RewriteCond in an .htaccess file and I am failing badly.

Heres what I have :

RewriteCond %{REQUEST_FILENAME} employee   [NC]
RewriteRule ^(.*)$ /resources/employee [L,R=301]

will redirect fine... but if I include any other rules that include 'employee' like this:

RewriteCond %{REQUEST_FILENAME} employee/another   [NC]
RewriteRule ^(.*)$ resources/employee/another [L,R=301] 

It redirects me to the first Rule: /resources/employee

I have tried many variations, but no luck. Any ideas?

+1  A: 

RewriteCond uses a regular expression, and searches your value for it. To make sure it only matches whole string, use the ^ and $:

RewriteCond %{REQUEST_FILENAME} ^employee$ [NC]
Radomir Dopieralski
+1  A: 
RewriteCond %{REQUEST_FILENAME} employee   [NC]

will match anything with employee in it, try using some anchoring, like to the beginning and end of filename or similar:

# Match everything that starts with /employee, might be followed by a slash and then ends
RewriteCond %{REQUEST_FILENAME} ^/employee/?$   [NC]
nicomen
yeah, noticed that... how can I stop it at the end of employee and then create another rule for employee/another and end it at another? Thats my problem. Right now, its redirecting all requests with employee in path to the same place.
croteau
like the example above?
nicomen