重定向子文件夹中htacess到的index.html重定向、文件、夹中、html

2023-09-02 20:40:25 作者:°mm/小男孩也卖萌

我要子目录(子文件夹)重定向到index.html页面。我怎样才能通过htaccess文件做到这一点。

I have to redirect sub-directory(subfolder) to their index.html page. How can I do it by htaccess file.

例如。

http://www.annonline.com/itineraries-prices/

当我输入这个网址,它应该被转发到

when I type this url,it should be forwarded to

http://www.annonline.com/itineraries-prices/index.html

请建议我怎么能做到这一点?

Please suggest that how can I do this?

在此先感谢。

推荐答案

要避免谷歌有您的网页复制的解决方案是包括:

The solution to avoid google having your page duplicated is to include:

<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish" />

你的页面在头部分。这个在谷歌博客详情

除此之外,在apache的水平,在的DirectoryIndex 指令设置的资源列表来寻找(见的阿帕奇文档) EJ:此指令设置的资源去寻找时,被请求的目录

Aside from this, at apache level, the DirectoryIndex directive sets the list of resources to look for (see apache docs) Ej: this directive sets the resources to look for when a directory is requested

DirectoryIndex index.php index.html  

如果您希望谷歌看到相同的资源,你应该做一个客户端再导向:

If you want google to see the same resource you should do a client redir:

RewriteRule ^/itineraries-prices/?$ http://www.annonline.com/itineraries-prices/index.html [R=301,L]