web hosting reviews


Duplicate content fix index.html vs / (slash only)

Web Hosting Articles \ A simple guide to .htaccess \ Duplicate content fix index.html vs / (slash only)


This similar to the www vs non-www version of your site work-around.

As you might now you, by default you can access your site as http://www.domain.com/ and http://www.domain.com/index.html with some setups it can be index.php or index.asp or default.aps, etc.

Unfortunately, this creates a risk of duplicate content from the search engine point of view. To avoid this, you can use the following ModRewrite rules in your .htaccess file:

RewriteEngine on 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.domain.com/ [R=301,L]

The file should be located in your website main folder (web root).

The rules above will tell the browser or the search engine both that all requests to index.html should be directed to the "/" (slash only).


  1. How to block users from accessing your site based on their IP address
  2. How to prevent or allow directory listing?
  3. How to change the error documents – 404 Page Not Found, etc
  4. Using .htaccess for password protecting your folders
  5. Using .htaccess to block referrer spam
  6. Disable Hot-Linking of images and other files
  7. Redirect URLs using .htaccess
  8. Introduction to mod_rewrite and some basic examples
  9. Force SSL/https using .htaccess and mod_rewrite
  10. 301 Permanent redirects for parked domain names
  11. Enable CGI, SSI with .htaccess
  12. How to add Mime-Types using .htaccess
  13. Change default directory page
  14. Block Bad robots, spiders, crawlers and harvesters
  15. Make PHP to work in your HTML files with .htacess
  16. Change PHP variables using .htaccess
  17. HTTP Authentication with PHP running as CGI/SuExec
  18. Force www vs non-www to avoid duplicate content on Google
  19. Duplicate content fix index.html vs / (slash only)

Comments 1 >>

Vacation Rentals Said,
Mar 06, 2008 @ 23:44

I see a lot of people telling how to do this fix & then also the www vs non www workaround, but not many people show how to combine both. Could you show an example of the htaccess file with both rules combined?

Would you mind emailing me if you update this?

Craig
Your comments on this article

(required)

(required but never displayed)



security code



Previous: Force www vs non-www to avoid duplicate content on Google Next: How to block users from accessing your site based on their IP address

Back to Web Hosting Articles list

Web hosting companies A-Z:
All web hosting companies


About - Terms of Use - Privacy Policy -
Web Hosting Reviews