Default HTACCESS


/ Published in: Apache
Save to your folder(s)

Good .htaccess file to start with.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.