开发者

mod_rewrite lexical comparison

NOTE: following code is surrounded by a RewriteCond/RewriteRule that skips the cases so they do not get ran again after the redirect takes place.

Why can't I get this to test true?

RewriteCond %{REQUEST_FILENAME} ="/unique/test/test"
RewriteRule ^.*$ /match [R=301,L]

I'm outputing everything with the following line and I can clearly see what REQUEST_FILENAME is:

RewriteRule (.*) /test$1-filename-%{REQUEST_FILENAME}-URI-%{REQUEST_URI} [R=301,L]

but I can't get it to match.

I was originally trying to do something like this to test if had modified the path from the original URI or not, but seeing as I cannot get the above to test true, this certainly does not work:

RewriteCond %{REQUEST_FILENAME} =%{REQUEST_URI} 开发者_如何学编程


In RewriteCond, variables are only expanded within the first argument. So with your RewriteCond you are actually comparing the value of REQUEST_FILENAME with the literal string %{REQUEST_URI}.

To do what you intended, you need to do some trick:

RewriteCond %{REQUEST_FILENAME}#%{REQUEST_URI} ^([^#]+)#\1$
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜