Friday, January 28, 2011

Redirect domain's content to another domain

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.

  • 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>
    
    Kris Sauquillo : Ah, thanks! One more minor question.. how would I make it so
    KayakJim : You could add those statements to either .htaccess or your apache configuration, depending whether you have root access or not.
    From KayakJim

0 comments:

Post a Comment