View Full Version : How to redirect non-www pages to www pages ?
senaia
11-27-2007, 10:42 AM
Hello
I want to redirect all the non-www forum url's including the main page, to www. Is there a mod/hack to do this for me ?
I tried a few commands in .htaccess, the main page would be redirected but the rest the pages would give an error page.
Any advice/help is appreciated. Thank You.
Vinyljunky
11-27-2007, 11:58 AM
I use In .htaccess
RewriteCond %{HTTP_HOST} !^www.mysitez.com$ [NC]
RewriteRule ^(.*)$ http://www.mysitez.com$1 [R=301,L]
VinylJunky
senaia
11-29-2007, 10:32 AM
Thanks but its not working for me.
Only the main page works and the non-www pages would give an error, instead of redirecting to www.
RedTyger
11-29-2007, 11:10 AM
Try this, my version is rather more complicated because it's done for multiple domains but I think this is how it started out.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com/$ [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301]
senaia
11-30-2007, 05:45 AM
Try this, my version is rather more complicated because it's done for multiple domains but I think this is how it started out.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com/$ [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301]
Hmm, nothing happens using this code. No errors or redirect or anything, it just stays the same. Anyway, thanks for taking the time to help :)
RedTyger
11-30-2007, 09:02 AM
Wikipedia says this: http://en.wikipedia.org/wiki/No-www#Apache_example
Amenadiel
11-30-2007, 12:34 PM
Try this, my version is rather more complicated because it's done for multiple domains but I think this is how it started out.
I believe this case is exactly the opposite, so it should go:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com/$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301]
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.