0

How do I auto forward/turn/convert (whatever the correct term is) URLs entered as www.example.co, www.example.co/blah/blah, example.co OR example.co/blah/blah to example.com or example.com/blah/blah? I basically want to push anything coming in with the www subdomain and that top level domain to forward to the new domain but include the paths (if any).

I'm using an shared web host provider running Apache web server.

Thanks in advance

crashintoty
  • 261
  • 1
  • 4
  • 11

1 Answers1

3

Put a .htaccess file in the root of the old domain once you have moved.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)example.co [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

The 301 will tell Google (and other bots) you have permanently moved. Some more info on the Rewrite can be found here: mod_rewrite cheat sheet

Bart De Vos
  • 17,911
  • 6
  • 63
  • 82
  • Thanks for your reply. Will this catch both www.example.co AND example.co? Also, I need outside sources (like search engines and bots) to NOT see this as a permanent change/move. The .CO domain is actually part of a marketing & advertising campaign and need everyone seeing/thinking this is as a real domain and keeping all spellings of it as *.CO. Only when the user gets to the site does the *.COM matter (its fine that users see the change from .co to .com when visiting). Is it possible to still forward and not have it known to the world as a forward? – crashintoty Feb 25 '11 at 09:15
  • If the redirect is temporary, you should change the 301 (end of 4th line) to 302. Google will discard the changes then. If example.co and www.example.co serve up the same pages now, you'll be fine with this code. If www.example.co is different from example.com (seems highly unlikely to me) just put this in the 2 different roots. – Bart De Vos Feb 25 '11 at 09:19
  • Thanks again TiZon. I hate to be a pain but I looked up 301 vs. 302 and you were absolutely right, but I discovered MSN/Bing and Yahoo will handle 302 like 301 unfortunately. Now I'm worried my campaign won't look as good. Here's a more specific example of what I'm trying to achieve: socialize.it, socialize.me, socialize.us (and www subdomain, if entered) and paths (if any) redirect to socialize.com. As you can probably figured out the *.it, *.me, *.us is part of the coolness of the web app/site and essential aesthetically. Everyone must see and use them. Is redirects still what I need? – crashintoty Feb 25 '11 at 18:08
  • I see. I think you would want one server and then a number of vhosts. This way, it's possible to use multiple domains that serve up the same content. More info to be found here: http://httpd.apache.org/docs/2.0/vhosts/examples.html Happy to help ;-) – Bart De Vos Feb 25 '11 at 19:07
  • I was worried that may be the case. Unfortunately I'm on a shared web host provider, I highly doubt I have access to stuff like that. I'll make do with your mod_rewrite solution for now. Thanks so very much TiZon! – crashintoty Feb 25 '11 at 19:44