我试图通过显示特定页面来防止浏览子目录中的文件,同时防止两个URL上的内容重复。
我在一个子目录中有几个文件,例如:
www.example.com/subfolderA/pageone.html
www.example.com/subfolderA/pagetwo.html
www.example.com/subfolderA/pagethree.html
etc
我不希望用户访问子目录本身(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
?
这也是满足我要求的最佳解决方案吗?
感谢您的帮助。
谢谢。
要删除重复页面,可以在/subfolderA/.htaccess
:中使用此规则
RewriteEngine On
RewriteBase /subfolderA/
RewriteCond %{THE_REQUEST} (/subfolderA)/?[?s] [NC]
RewriteRule ^$ %1/pageone.html [L,R=301]