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文件夹和文件名在url重写中冲突_.htaccess - Fatal编程技术网

.htaccess文件夹和文件名在url重写中冲突

.htaccess文件夹和文件名在url重写中冲突,.htaccess,.htaccess,我有以下权限,不允许url中有任何文件扩展名: Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php 我的问题是,我有一个名为images.php的文件和一个名为images的文件夹,所以当我使用url时:.com/images-它会将我带到images文件夹,其中as:.

我有以下权限,不允许url中有任何文件扩展名:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php

我的问题是,我有一个名为images.php的文件和一个名为images的文件夹,所以当我使用url时:.com/images-它会将我带到images文件夹,其中as:.com/contact-会将我带到正确的页面。

RewriteCond%{REQUEST\u FILENAME}-f
RewriteCond%{REQUEST\u FILENAME}-d

在这两行代码中,如果测试字符串(在您的示例中为“images”)不是目录,也不是文件,则将其重写为images.php。现在,由于您有images目录,第二条规则不满足,images被重写为images.php internaly


要么更改文件夹名称,要么更改脚本名称,要么更改.htaccess规则和条件。

我认为,如果您在规则之前添加此规则,则此规则应该可以工作…(但我没有测试它)

按照建议,删除
RewriteCond%{REQUEST\u FILENAME}-d
行将修复该问题

您的规则应如下所示:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ $1.php

带你去哪里…com/images/?你说你已经尝试删除
RewriteCond%{REQUEST\u FILENAME}-d
?嘿,我也有同样的问题,你有没有找到解决办法?我也有这个问题。有什么解决方案吗?我要将htacces条件更改为什么?我尝试了-f和-d的每一种组合,将它们删除并反转(!),但它仍然会首先查找文件夹
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ $1.php