Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

how can i redirect two domain on the same server.. let say this domains

http://www.game.com -> http://www.games.com
http://game.com -> http://www.games.com
http://games.com -> http://www.games.com (*this is not redirecting*)

all domain all should redirect to this domain http://www.games.com

heres the current htaccess content

RewriteCond %{HTTP_HOST} ^game.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.game.com$
RewriteRule ^/?$ "http\:\/\/www\.games\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^games.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.game.com$
RewriteRule ^/?$ "http\:\/\/www\.games\.com\/" [R=301,L]
share|improve this question

marked as duplicate by Jenny D, Katherine Villyard, Tim Brigham, Dave M, mdpc Mar 14 at 1:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

Everyone loves to use mod_rewrite when there's often a much simpler way of doing the same thing. This uses mod_alias.

<VirtualHost *:80>
  ServerName game.com
  ServerAlias www.game.com
  ServerAlias games.com
  Redirect permanent / http://www.games.com
</VirtualHost>
<VirtualHost *:80>
  ServerName www.games.com
  .
  .
  .
</VirtualHost>
share|improve this answer

mod_rewrite seems overkill. If you have access to the vhost configs, then you can simplify by capturing the Hosts in a single vhost and use RedirectMatch.

<VirtualHost *:80>
    ServerName games.com
    ServerAlias game.com www.game.com

    RedirectMatch permanent .* http://www.games.com/
</VirtualHost>
share|improve this answer
    
i dont have access to vhost configs.. can i do this in htaccess? –  yoshi Oct 21 '09 at 10:04
    
This should be doable in htaccess, and redirect is a much better way to do it. –  LapTop006 Oct 21 '09 at 10:27
1  
You can use RedirectMatch in a directory/.htaccess context. But how you apply it will depend very much upon how your vhosts are configured. It would be best to update your question to include them. –  Dan Carley Oct 21 '09 at 10:28

That last RewriteCond shouldn't be necessary -- it's a duplicate of the second condition in the first rule.

Without seeing your full Apache config I can't say for sure, but the most common cause of this sort of problem in my experience is when the vhost that you've put the rewrite in for doesn't actually cover the hostname, and some other vhost config is being used for the domain.

share|improve this answer