开发者

Apache rewrite exclude

How do I exclude "404.php" from matching thi开发者_运维知识库s rewrite rule?

RewriteRule ^([0-9]+)/?.*$ /news.php?sid=$1


Untested but should work:

RewriteCond %{REQUEST_URI} !^/404\.php
RewriteRule ^([0-9]+)/?.*$ /news.php?sid=$1 


Just catch it with a previous rule that has the last flag set:

RewriteRule ^(404.php)$ $1 [NC,L]

RewriteRule ^([0-9]+)/?.*$ /news.php?sid=$1 [NC,L]


 RewriteCond %{REQUEST_URI} !^/404\.php$ 
 RewriteRule ^([0-9]+)/?.*$ /news.php?sid=$1

RewriteCond is used to match request URIs for which the following rule should be applied to.

You can learn more here about the header variables that can be used in RewriteCond statements: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜