与子文件夹index.html的友好URL冲突



我目前有一个。htaccess包含这些mod_rewrite规则:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>`

对于我的主要项目的友好URL,它工作得很好,但是当我试图通过URL/子文件夹/或/子文件夹访问/子文件夹/index.html时,我有一个冲突,它循环。

我尝试了很多事情没有成功,我想我必须使用RewriteCond %{REQUEST_FILENAME} -d,然后使RewriteRule到index.html,但是当我成功了,然后URL/响应了一个权限拒绝错误。

我如何使子文件夹去它自己的index.html,仍然有友好的url ?

说明:友好的url不会也永远不会匹配现有的文件夹

可以同时使用DirectoryIndexRewriteCond %{REQUEST_FILENAME} -d:

DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1 [L,R=301,NE]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule

最新更新