重写规则,如果条件不匹配 [英] Rewrite rule if condition is not matched
问题描述
我如何可以执行规则,如果URL是不匹配的路径论坛
例如:
的RewriteCond如果URL不是论坛
重写规则(JS | GIF | CSS | JPG | PNG)!$
%{DOCUMENT_ROOT}的index.php [L]
块引用>解决方案Apache的<一个href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond\"><$c$c>RewriteCond$c$c>以及在<一个href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond\"><$c$c>RewriteRule$c$c>指令支持感叹号来指定一个非匹配模式:
您可以preFIX模式字符串
一个 '!'字符(惊叹号)来
指定非匹配模式。
块引用>这应该工作:
的RewriteCond%{REQUEST_URI}!^ /论坛。*
!重写规则\\。(JS | GIF | CSS | JPG | PNG)$的index.php [L]- >重定向所有请求不的论坛的而不是列出足够的index.php期末数期初数
How may I perform a rule if the url is NOT matching the path "forums"
For example:
RewriteCond IF URL IS NOT forums
RewriteRule !.(js|gif|css|jpg|png)$ %{DOCUMENT_ROOT}/index.php [L]
解决方案Apache's
RewriteCond
as well as theRewriteRule
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
这篇关于重写规则,如果条件不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!