Aug 14, 2011
tom

Redirect domain’s content to another domain

Question

1) How would I redirect user1.domain.com to display domain.com/user?id=1 content?

2) How would I redirect domain1.com to display sub.domain2.com’s content?

I have both domains on the same server/host, so I don’t think changing A records in the DNS is the issue.

Answer

The following assumes that you are using Apache.

1) How would I redirect user1.domain.com to display domain.com/user?id=1 content?

Something like the following should work although I haven’t tested it:

RewriteEngine On
RewriteCond %{HTTP_HOST}  ^user1.domain.com [NC]
RewriteRule . http://domain.com/user?id=1 [L,R]

2) How would I redirect domain1.com to display sub.domain2.com’s content?

<VirtualHost *:80>
  ServerName domain1.com
  Redirect 302 / http://sub.domain2.com/
</VirtualHost>

Related posts:

  1. How can I have an Apache server at a single IP which serves different content to requests for different domain names?
  2. SPF include vs redirect
  3. VirtualHost not directing properly based on domain name
  4. Redirect ALL Traffic to single page if a domain matches
  5. Merge two different domains but save virtualhost with Apache redirect

Leave a comment