2011-05-19 79 views
0

如果我将“/index.html”重定向到“/”,是否允许浏览我的网站,因为它不再有页面标题为“/index.html”还是被重定向到(www.sample.com/)的页面仍然作为索引(默认)页面,从而防止目录被暴露?如果您有索引页面,Web服务器不会让您浏览目录,但是重定向仍然保持索引页面,但不会显示在URL中?将www.sample.com/index.html重定向到www.sample.com以避免重复

我想知道在做这个改变之前,而不仅仅是试验。我只是在服务器上有一个域,并打算使用以下脚本之一在我的.htaccess文件的建议他人:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/ 
RewriteRule ^(([^/]+/)*)index\.html$ http://www.sample.com/$1 [R=301,L] 

RewriteCond %{THE_REQUEST} ^.*/index.html 
RewriteRule ^(.*)index.html$ http://www.sample.com/$1 [R=301,L] 

任何意见或建议被赞赏。

回答

0

尝试改变的index.html的index.php,而只是将其重定向到www.sample.com

0

选项Indexes在Apache中负责浏览网站上的文件和目录。 将Options -Indexes写入.htaccess,它将禁止这种暴露。