0

I have a website, say www.xyz.com I have another website hosted app.xyz.com

I am looking at redirecting all the subdomain requests to app.xyz.com.

e.g a.xyz.com - app.xyz.com

b.xyz.com - app.xyz.com

c.xyz.com - app.xyz.com

The url in the browser needs to remain a.xyz.com, b.xyz.com or c.xyz.com

Can you help me with the steps involved. What needs to be done in DNS and what rewrite rule needs to be written for IIS. ( For this I don't want to create any folders, sub-domains, binding rules, etc for every entry.)

Will the above work with http and https ?

TIA.

Tushar
  • 1,242
  • 1
  • 8
  • 19

1 Answers1

0

If you have the www.xyz.com set up correctly, you may simply use the following ISAPI_Rewrite rule to resolve this:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} ^(?!www\.).+$ [NC]
RewriteCond %{HTTP:Host} ^[^.]+\.xyz\.com$ [NC]
RewriteRule .* http://app.xyz.com [NC,R=301,L]
Andrew
  • 511
  • 3
  • 7
  • Andrew, Thanks a ton for replying. But the issue is that I have three different websites. 1. www.xyz.com ,2. app.xyz.com and 3 admin.xyz.com . I want any website other than www and admin should be rewritten to app.xyz.com. In case the user types tushar.xyz.com , he should be able to see the content from app.xyz.com but the URL in the browser should remain tushar.xyz.com. If I setup up www with blank binding redirect works but rewrite doesn't work. It gives 404 error. I added the rules you mentioned to the website. Will adding these rules to the IIS server root level help ? – Tushar Aug 22 '12 at 10:57