Php Apache重写模块跳过路径
如何告诉apache重写模块跳过重写某个路径,目前我在.htaccess中有以下代码Php Apache重写模块跳过路径,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,如何告诉apache重写模块跳过重写某个路径,目前我在.htaccess中有以下代码 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !^(ampache)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] 重新启动发动机 重写cond%{REQUEST_FILENAME}^(安帕奇)$ 重写cond%
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^(ampache)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
重新启动发动机
重写cond%{REQUEST_FILENAME}^(安帕奇)$
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
具体来说,我想让以ampache
开头的路径通过而不被重写。
上面的代码不能满足我的需要。使用
请求URI
而不是请求文件名
,因为请求文件名
匹配完整的文件系统路径
您可以使用此已更正的规则:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/ampache(/.*)?$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
甚至这种否定模式也会起作用:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^/?ampache(/.*)?$ index.php [L,NC]
我想要的是,当path=
ampache
yes时,不要重定向到index.php,这就是这个规则所做的。如果URI以/ampache
开头,则上述规则将不会路由到index.php