简体   繁体   中英

Redirect subfolder to index.html in htaccess

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

eg

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

when I type this url,it should be forwarded to

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

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" />

in the head section of your page. Details about this at google blog

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM