Require the www via mod_rewrite - additional conditions needed?
To rewrite example.com to www.example.com I was told to use the following rules within my root .htaccess file:
# Require the www
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/robots\.txt$
RewriteCond %{REQUEST_URI} !^/sitemap\.xml$
RewriteCond %{REQUEST_URI} !^/favicon\.ico$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Could you please explain what's the matter 开发者_运维技巧with the first five lines here? Are they really needed/recommended? TIA
.htaccess tricks This article will help you to understand all the tricks about htaccess . Later yourself decide whether you need first five lines
Hope its helpful
精彩评论