Okay... a new idea for people, I bet everyone has gone to type a website, www.domain.co.uk and only typed two w's i.e. ww.domain.co.uk or even double pressed the key to get four w's i.e. wwww.domain.co.uk. So I want to help the visitors to my websites that do this easy mistake. In my DNS I have added ww. and wwww. to my C name. In apache I have added the following into the Apache conf in the VirtualHost... ServerName domain.co.uk ServerAlias ww.domain.co.uk ServerAlias www.domain.co.uk ServerAlias wwww.domain.co.uk All of these are setup and working, you can enter ww.domain.co.uk and it loads the site. At the moment the only bit of kit I have setup is for if someone types http://domain.co.uk/ it will send them to http://www.domain.co.uk/ Can someone please help me to change... RewriteCond %{HTTP_HOST} ^domain\.co\.uk RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301] To also rewrite ww.domain.co.uk to www.domain.co.uk and wwww.domain.co.uk to www.domain.co.uk I already thought about adding a new line of... RewriteRule ^http://ww.domain.co.uk/$ http://www.domain.co.uk/ [R=301,L] But that wont work if someone types in ww.domain.co.uk/page.php Can someone please help with this RewriteCond!? Many Thanks.
Hey Thought this may be of help to you http://www.widexl.com/tutorials/mod_rewrite.html Regards, SSANZ
Thanks, I got it working by doing the following... RewriteCond %{HTTP_HOST} ^domain\.co\.uk$ [NC] RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^ww\.domain\.co\.uk$ [NC] RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^wwww\.domain\.co\.uk$ [NC] RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301] Does anyone know how to correctly use the [OR] command to tidy up this code?
Thanks, got it finished by doing... RewriteCond %{HTTP_HOST} ^domain\.co\.uk$ [NC,OR] RewriteCond %{HTTP_HOST} ^ww\.domain\.co\.uk$ [NC,OR] RewriteCond %{HTTP_HOST} ^wwww\.domain\.co\.uk$ [NC] RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301]