开发者

Apache rewrite exclude

开发者 https://www.devze.com 2023-02-04 05:02 出处:网络
How do I exclude \"404.php\" from matching thi开发者_运维知识库s rewrite rule? RewriteRule ^([0-9]+)/?.*$ /news.php?sid=$1

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

精彩评论

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

关注公众号