301 redirect non-www to www
Sunday, February 19th, 2006In continuation of the theme ‘using my blog as a personal notepad’, here’s a small snippet for use in an Apache .htaccess file to ensure that visitors/incoming links not using the www. form of your site’s domain are redirected correctly.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.co\.uk
RewriteRule (.*) http://www.example.co.uk/$1 [R=301,L]
Make sure to escape periods in the RewriteCond line with [...]
