Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 放弃htaccess中的重写规则_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 放弃htaccess中的重写规则

.htaccess 放弃htaccess中的重写规则,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,php中的permalink有两个重写规则 RewriteRule ^(.*).htm index.php [NC,QSA,L] RewriteRule ^(.*).html index.php [NC,QSA,L] 我需要浏览静态html文件: /uploads/themes/mail-signature/mail-signature.html 但是当我输入http://example.com/uploads/themes/mail-signature/mail-signature.htm

php中的permalink有两个重写规则

RewriteRule ^(.*).htm index.php [NC,QSA,L]
RewriteRule ^(.*).html index.php [NC,QSA,L]
我需要浏览静态html文件:

/uploads/themes/mail-signature/mail-signature.html
但是当我输入
http://example.com/uploads/themes/mail-signature/mail-signature.html
它正在显示
index.php

我怎样才能放弃这些规则

您的第二条规则实际上并没有做任何事情,因为任何
.html
请求都将被第一条规则捕获。因此,第二条规则可以删除

然后,向第一条规则添加一个条件,该条件排除您试图访问的特定URL。例如:

RewriteCond %{REQUEST_URI} !^/uploads/themes/mail-signature/mail-signature\.html$
RewriteRule \.html?$ index.php [NC,L]
此处不需要
QSA
标志,因为默认情况下会传递任何查询字符串

重写规则
模式上的
^(.*)
前缀不是必需的,因为您没有使用此反向引用

您应该反斜杠转义正则表达式中的任何文字点,例如
\.htm
,否则您将匹配任何字符,例如“xhtml”。大概您只想匹配以
.htm
.html
结尾的URL?您的原始正则表达式将与请求URL中的任意位置匹配“htm”

您的第二条规则实际上并没有做任何事情,因为任何
.html
请求都将被第一条规则捕获。因此,第二条规则可以删除

然后,向第一条规则添加一个条件,该条件排除您试图访问的特定URL。例如:

RewriteCond %{REQUEST_URI} !^/uploads/themes/mail-signature/mail-signature\.html$
RewriteRule \.html?$ index.php [NC,L]
此处不需要
QSA
标志,因为默认情况下会传递任何查询字符串

重写规则
模式上的
^(.*)
前缀不是必需的,因为您没有使用此反向引用

您应该反斜杠转义正则表达式中的任何文字点,例如
\.htm
,否则您将匹配任何字符,例如“xhtml”。大概您只想匹配以
.htm
.html
结尾的URL?原始正则表达式将与请求的URL中的任意位置“htm”匹配。

要么添加一个RewriteCond(在每个规则之前)来检查请求的URI是否不匹配,要么在两个现有的RewriteRule之前添加另一个RewriteRule,该规则匹配该确切路径,但根本不进行重写(
-
作为替换),并使用
L
E
标志在此时退出流程。要么添加一个RewriteCond(在每个规则之前)检查请求的URI是否不是该URI,要么在两个现有URI之前添加另一个RewriteRule,该规则与该确切路径匹配,但根本不进行重写(
-
作为替换),并使用
L
E
标志在此时退出流程。