我想在那捕捉一切眼福直到那时一个.htaccess文件的末尾来创建一个规则。
I want to create a rule at the end of an .htaccess file that catches everything that failed to match up until then.
我怎么能这样做?
P.S。我已经尝试了一切:)其实,我没有,但可以肯定,似乎喜欢它!的
更新:有些人回答与重写规则^ * $ 或等效的。 这不起作用!这将匹配的所有的,包括其他的好的网址。
Update: Some people are replying with RewriteRule ^.*$ or an equivalent. This does not work! It will match everything including the other 'good' URLs.
推荐答案实际上有一些很好的答案,在这里了,但你有回应...
There are actually some good answers here already, but you have responded with...
但后来这匹配的一切,包括好东西。
But then this matches everything including the good stuff.
这是因为你没有告诉mod_rewrite的停止处理上的匹配。要做到这一点,用L标记每个规则,它告诉mod_rewrite的后说,如果这条规则匹配,停止处理任何进一步的规则。
This is because you aren't telling mod_rewrite to stop processing on a match. To do this, use the "L" tag after each rule, which tells mod_rewrite that "If this rule is matched, stop processing any further rules".
RewriteRule ^RSS/([^/\.]+)/?$ rss.php?Page=$1 [L]您需要每个规则后,把这个。然后,当你把捕获的所有底,它只会在没有其他规则已被匹配命中。
You need to put this after EACH rule. Then, when you put the catch all at the end, it will only be hit if no other rule has been matched.
请注意:如果您还提供了未改写,如CSS,图片,JavaScript文件等资源 - 你是诚实最好不要再追所有,你会不会想重写它们的位置
NOTE: if you are ALSO serving up resources that are not rewritten, like CSS, images, javascript files - you are honestly better off not catching all as you wouldn't want to rewrite their locations.
更多推荐
如何使一个包罗万象的处理程序在.htaccess文件?
发布评论