我有一个htaccess规则,它将索引.html重定向到索引.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}' /.*index'.html' HTTP/
RewriteRule ^(.*)index'.html$ /$1index.php [R=301,L]
这工作正常 - 当我打电话给 http://mydomainname.com/index.html 时,它会将我重定向到 http://mydomainname.com/index.php
但是我遇到了一个问题,当子文件夹中有一个名为 index 的文件时.html我的 htaccess 规则会将其带到 index.php。
示例 - http://mydomainname.com/subfolder/index.html http://mydomainname.com/subfolder/index.php,子文件夹不应发生这种情况。
有什么解决办法吗?
对于您正在做的事情来说,该规则可能有点过于复杂。
您只需要:
RewriteRule ^index.html$ /index.php [R,L]
试试这个。它在我的情况下有效。
RewriteEngine On
RewriteBase /
RewriteRule ^index'.html?$ / [NC,R,L]
访问: https://css-tricks.com/how-to-redirect-indexhtml-to-indexphp/