1 Answers1

2

Some more information about your setup would be good, but essentially:

RewriteRule ^/$ http://my.name.com/ [R=301,L]

That's for in your virtual host configs for the domains that are redirecting; if it's in an htaccess or <Directory> block then you'll need to remove path information:

RewriteRule ^$ http://my.name.com/ [R=301,L]

..and if it's in a location like an htaccess that applies to all of the domain names, then you'll need to have it not redirect for the target domain.

RewriteCond %{HTTP_HOST} !^my\.name\.com$ [NC]
RewriteRule ^$ http://my.name.com/ [R=301,L]
Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Doesn't this redirect everything to my.name.com? I'm looking to only redirect when the URL is exactly http://www.name.com or http://name.com – Michael Oct 25 '12 at 01:23
  • @Michael Nope! My match string in the first one is `^/$` - it must be an ***exact*** match, with the start and end of the string directing preceding and following the slash. Within a `` or `.htaccess` context, the directory path is stripped, so a request for `http://name.com/` comes in to `mod_rewrite`'s match process as an empty string, which is exactly what `^$` will match in the second and third examples. – Shane Madden Oct 25 '12 at 01:27