开发者

RewriteCond not stopping at end.. /example will work... but example/anotherlink doesnt

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开发者_StackOverflow/employee/another [L,R=301] 

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

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


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]


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜