-1

如何使用 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 实际存在于目录中

4

1 回答 1

0
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]

index.html此代码将重定向以(文件实际存在的位置)结尾的所有内容。

于 2013-04-12T12:57:30.837 回答