Forum Moderators: phranque
I'm trying to tidy up a situation where widgets.example.com has been set up as a virtualhost in www.example.com. So widgets.example.com is the same as www.example.com/widgets.
To make matters worse, someone has gone and gathered a lot of links to www.widgets.example.com. I'd like to make all three versions appear the same to google and lead to the same URL.
So:
all requests to widgets.example.com remain unchanged (go to widgets.example.com);
all requests to www.example.com or www.widgets.example.com are rewritten to the same path at widgets.example.com;
all requests to bodgets.example.com are unaffected (go to bodgets.example.com - this for all virtuals other than widgets).
I tried using
Redirect permanent / [widgets.example.com...]
in the htaccess in the www root, but it got picked up by the /widgets folder, sending the server in a loop. All the examples I've found are based on rewriting paths rather than the host name.
Could I do something with a RewriteCond and HTTP_HOST?
I'm not familiar with these modules and I don't have a test environment to safely break, so any help would be appreciated.