Reputation: 39
I have a site where regardless of what is placed instead of "www", the site still works:
ie. abc.example.com, w.example.com, wwww.example.com, ww.example.com, etc
What I need to do is redirect all of this to the "www" url.
Any help would be of great help
Regards,
Sushil
Upvotes: 1
Views: 131
Reputation: 1285
I think you're looking for something like this:
RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
This should rewrite any URL that someone goes to at "example.com" that does not begin with www
to the URL with the www at the beginning. Note, you may choose to use <IfModule mod_rewrite.c>
in the case the mod_rewrite is ever disabled or uninstalled.
Upvotes: 1