Return to Snippet

Revision: 40612
at February 17, 2011 03:48 by batfan


Updated Code
RewriteEngine On 

# strip out querystrings for bots
RewriteCond %{HTTP_USER_AGENT} Google [NC,OR]
RewriteCond %{HTTP_USER_AGENT} MSNBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Slurp [NC]
RewriteCond %{QUERY_STRING} .
RewriteRule ^(.*)$ /$1? [L,R=301]

# rewrite second level to third level
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# rewrite index.html to root
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]

#Define friendly 404 page
ErrorDocument 404 /404.html

Revision: 40611
at February 4, 2011 08:38 by batfan


Initial Code
RewriteEngine On 

# strip out querystrings for bots
RewriteCond %{HTTP_USER_AGENT} Google [NC,OR]
RewriteCond %{HTTP_USER_AGENT} MSNBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Slurp [NC]
RewriteCond %{QUERY_STRING} .
RewriteRule ^(.*)$ /$1? [L,R=301]

# rewrite second level to third level
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# rewrite index.html to root
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]

#ErrorDocument 404 /404.html

Initial URL


Initial Description
Good .htaccess file to start with.

Initial Title
Default HTACCESS

Initial Tags
htaccess

Initial Language
Apache