Posted By

batfan on 02/04/11


Tagged

htaccess


Versions (?)

Default HTACCESS


 / Published in: Apache
 

Good .htaccess file to start with.

  1. RewriteEngine On
  2.  
  3. # strip out querystrings for bots
  4. RewriteCond %{HTTP_USER_AGENT} Google [NC,OR]
  5. RewriteCond %{HTTP_USER_AGENT} MSNBot [NC,OR]
  6. RewriteCond %{HTTP_USER_AGENT} Slurp [NC]
  7. RewriteCond %{QUERY_STRING} .
  8. RewriteRule ^(.*)$ /$1? [L,R=301]
  9.  
  10. # rewrite second level to third level
  11. RewriteCond %{HTTP_HOST} !^www\. [NC]
  12. RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  13.  
  14. # rewrite index.html to root
  15. RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
  16. RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
  17.  
  18. #Define friendly 404 page
  19. ErrorDocument 404 /404.html

Report this snippet  

You need to login to post a comment.