.htaccess mod_将/dir/index.html重写为/dir/
如何使用htaccess自动更改此选项:.htaccess mod_将/dir/index.html重写为/dir/,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,如何使用htaccess自动更改此选项: /dir1/index.html -> /dir1/ (with 301 redirect) /dir1/subdir1/index.html -> /dir1/subdir1/ (with 301 redirect) ... /another_dir/index.html -> /another_dir/ (with 301 redirect) /another_dir/another_subdir1/index.html -&g
/dir1/index.html -> /dir1/ (with 301 redirect)
/dir1/subdir1/index.html -> /dir1/subdir1/ (with 301 redirect)
...
/another_dir/index.html -> /another_dir/ (with 301 redirect)
/another_dir/another_subdir1/index.html -> /another_dir/another_subdir1/ (with 301 redirect)
等等
文件index.html实际存在于目录中
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
此代码将重定向以
index.html
(文件实际存在的位置)结尾的所有内容。此结构不支持子文件夹和/other_dir/other_subdir 1/index.html将更改为/other_subdir/它应该可以工作,因为*
捕获组包含正向斜杠。你试过了吗?您的.htaccess
文件在哪里?我的htaccess AddDefaultCharset utf-8 RewriteEngine On RewriteCond%{REQUEST_FILENAME}-f RewriteRule^(.*)/index\.html$$1/[R=301,L]它做什么?文件在服务器上的位置是什么?它在公共根目录中吗?我的htaccess AddDefaultCharset utf-8 RewriteEngine On RewriteCond%{REQUEST_FILENAME}-f RewriteRule^(.*)/index\.html$/$1/[R=301,L],实际结构是: