【发布时间】:2014-11-17 07:37:18
【问题描述】:
我试图通过显示特定页面来防止浏览子目录中的文件,同时防止两个 URL 上的重复内容。
我在一个子目录下有几个文件,例如:
www.example.com/subfolderA/pageone.html
www.example.com/subfolderA/pagetwo.html
www.example.com/subfolderA/pagethree.html
等等
我不希望用户访问子目录本身 (www.example.com/subfolderA/) 并查看所有文件的列表。相反,我希望它们被定向到特定页面(不一定称为“index.html”),比如说pageone.html。
我已将以下内容放入该子目录中的 .htaccess 文件中:
DirectoryIndex pageone.html
虽然这会阻止浏览文件并显示我想要的页面,但它会导致重复页面出现在搜索引擎中。
www.example.com/subfolderA/ 和 www.example.com/subfolderA/pageone.html
如何确保子目录本身不会被搜索引擎索引 - 即始终将浏览器中的 URL 更新为 www.example.com/subfolderA/pageone.html?
这也是满足我要求的最佳解决方案吗?
任何帮助表示赞赏。
谢谢。
【问题讨论】:
标签: apache .htaccess mod-rewrite seo directoryindex