0

I have a domain mysite.com which hosts asp.net website. I want to add virtual sum-domain user1.mysite.com , user2.domain.com etc without adding sub-domain under DNS.

I have tried couple URL rewriting option suggested in Stackoverflow itself. but it didn't work.

when hit www.mysite.com it taking to me the redirect/rewrite path. but other than www everything loads with default IIS7 page. Do we really need sub-domain to be created under DNS?

Can't we do it programmatically?

Can you anyone please explain in a step by step to implement this?

Vivek Sachan
  • 1
  • 1
  • 1
  • 3
  • http://stackoverflow.com/questions/458757/wildcard-subdomains-in-iis7-is-it-possible-to-make-them-like-it-is-in-apache – CodeCaster May 26 '16 at 08:34

1 Answers1

0

Of course you can achieve it in IIS 7 (proof: http://learn.iis.net/page.aspx/468/using-global-and-distributed-rewrite-rules/)

The main point is defining your custom regex and action pattern to rewrite your plain ASPX pages into custom subdomain format.

However, the rewrite rule still have chance to overwrite "www" before your domain name (e.g. www.example.com). To prevent this weird behavior, add this condition at beginning of rewrite collection:

<add input="{HTTP_HOST}" pattern="^www\." negate="true" />

Source: https://forums.iis.net/t/1161322.aspx?URL+rewrite+for+subdomain+to+subfolder

I hope this explanation helpful.

Tetsuya Yamamoto
  • 24,297
  • 8
  • 39
  • 61