Why does htaccess RewriteRule ^foo$ also match ^foobar$

纵然是瞬间 提交于 2019-12-21 23:32:47

问题


I want these URL redirects / forwards:

here.com/foo    ==> there.com/a/b
here.com/foobar ==> there.com/c/d

I have these two .htaccess RewriteRule lines:

RewriteRule ^foo$    http://there.com/a/b [R=301,L] 
RewriteRule ^foobar$ http://there.com/c/d [R=301,L]

But the result is:

here.com/foo    ==> there.com/a/b
here.com/foobar ==> there.com/a/b

foo is also matching foobar How do I make it work?


回答1:


This was a browser caching issue. I initially had the rules wrong. I changed the rules to those listed above, but because I'm using HTTP status code 301 (Moved Permanently), the browser was caching it and not getting the new request from the server. I tried a Chrome Incognito Window and discovered the issue.

Note that setting the HTTP status code to 303 (See Other) causes the browser not to cache it.



来源:https://stackoverflow.com/questions/11357304/why-does-htaccess-rewriterule-foo-also-match-foobar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!