/ Published in: Apache
Rewrite your urls for domain.co.uk to www.domain.co.uk including full url
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
In your Virtual Host declaration add a ServerAlias under your ServerName declaration for example you would have ServerName www.domain.co.uk ServerAlias domain.co.uk This on it's own would mean that visitors will be sent to your site with or without the www. prefix. What we can do is take the url they entered for example domain.co.uk/news/wow-look-at-this and rewrite it to www.domain.co.uk/news/wow-look-at-this All you need to do is; within your .htaccess file for the site add the following at the top RewriteCond %{HTTP_HOST} ^domain\.co.uk RewriteRule ^(.*)$ http://www.domain.co.uk/$1 [R=301,L]