小编D3S*_*ems的帖子

htaccess仅将index.html重定向到index.php

我有一个htaccess规则,它将index.html重定向到index.php

  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
  RewriteRule ^(.*)index\.html$ /$1index.php [R=301,L]
Run Code Online (Sandbox Code Playgroud)

这很好 - 当我调用http://mydomainname.com/index.html时,它会将我重定向到http://mydomainname.com/index.php

但是我遇到了一个问题,当子文件夹中有一个名为index.html的文件时,我的htaccess规则将其带到index.php.

示例 - http://mydomainname.com/subfolder/index.htmlhttp://mydomainname.com/subfolder/index.php,这不应该发生在子文件夹中.

有解决方案吗

php apache .htaccess mod-rewrite redirect

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

.htaccess ×1

apache ×1

mod-rewrite ×1

php ×1

redirect ×1