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.

link|improve this question

71% accept rate
feedback

1 Answer

up vote 2 down vote accepted

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>
link|improve this answer
Ah, thanks! One more minor question.. how would I make it so – Kris Sauquillo Oct 7 '10 at 23:58
You could add those statements to either .htaccess or your apache configuration, depending whether you have root access or not. – KayakJim Oct 8 '10 at 13:14
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.