Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/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 mod_将/dir/index.html重写为/dir/_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess mod_将/dir/index.html重写为/dir/

.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

如何使用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 -> /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],实际结构是: