开发者

Rewrite rule if condition is not matched

How may I perform a rule if the URL is NOT matching the path "forums"?

For example:

RewriteCond IF URL IS开发者_StackOverflow NOT forums
RewriteRule !\.(js|gif|css|jpg|png)$ %{DOCUMENT_ROOT}/index.php [L]


Apache's RewriteCond as well as the RewriteRule directive support the exclamation mark to specify a non-matching pattern:

You can prefix the pattern string with a '!' character (exclamation mark) to specify a non-matching pattern.

This should work:

RewriteCond %{REQUEST_URI} !^/forums.*
RewriteRule !\.(js|gif|css|jpg|png)$ /index.php [L]

--> redirect all requests not beginning with forums and not ending with the listed suffices to index.php

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜