Easier canonical url management in .htaccess
I was looking for a quick way to make sure all my multisites are using a www. url, and I found this patch which was committed to Drupal 7: Better, multi-site friendly "www." addition/removal in .htaccess. While this won't be committed to Drupal 6, it's very easy to use it manually in your .htaccess file. Here are the relevant snippets (only use one of them depending on whether you want to www. prefix or not):
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
Add new comment