Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Php htaccess从重写规则中忽略/排除文件夹_Php_.htaccess_Mod Rewrite - Fatal编程技术网

Php htaccess从重写规则中忽略/排除文件夹

Php htaccess从重写规则中忽略/排除文件夹,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我有这个剧本: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/?(images|orders)/ RewriteRule ^(.*)$ index.php?til=$1 [L,QSA] 它在我的本地主机上运行良好,但当我将它上传到主机并转到www.domain.com/images/时,它会重定向到i

我有这个剧本:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/?(images|orders)/

RewriteRule ^(.*)$ index.php?til=$1 [L,QSA]

它在我的本地主机上运行良好,但当我将它上传到主机并转到
www.domain.com/images/
时,它会重定向到
index.php?til=403.shtml

好的,这似乎很有效

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/orders/.* [NC]
RewriteCond %{REQUEST_URI} !^/401.shtml [NC]
RewriteCond %{REQUEST_URI} !^/403.shtml [NC]

RewriteRule ^(.*)$ index.php?til=$1 [L,QSA]

mod_rewrite反复扫描htaccess文件,直到不再进行替换。[L]标志表示“本周期的最后一个”。W.e.f.Apache 2.4[End]标志符合您的意愿。有关更多讨论,请参阅我的

我怀疑问题在于Dhard主机启用了多视图,而您在dev实例上没有启用多视图。始终尝试尽可能多地将您的dev实例与宿主提供程序对齐。如果不需要,请始终禁用“多视图”


通过添加[NS]标志,您始终可以根据每个规则禁用此功能。在本例中,如果您将其添加到第一条规则中,您将发现它现在可以工作。

Live server导致403,你需要找出原因吗?是的,这是因为在我的本地主机上显示了
禁止你没有权限访问此服务器上的/images/。
在我的实时服务器上,我得到:
禁止你没有权限访问此服务器上的/images/。此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。
那么问题是为什么禁止使用
/images/
文件夹?我想我的主机默认阻止索引
-indexes
,在这种情况下,您不应该尝试打开
/images/
来列出所有图像。是的,但这是一个变通办法,不是答案:-)我会为你发布一个答案。