Search code examples
asp.netdnswindows-server

Redirect any sub-domain to main domain by editing DNS Record


Is it possible to redirect any sub-domain to the main domain by editing DNS Record in Windows Server? (ASP.NET WinForm)

example:

abc.domain.com >> www.domain.com
xyz.domain.com >> www.domain.com

What DNS Record should I add?
Can a CNAME record solve this problem?

Example of a CNAME record:

Name: *.domain.com
Type: CNAME
Data: www.domain.com


Solution

  • The CNAME is what you're looking for, although there is another alternative, you can create a .htaccess file that you'd put in the root of the subdomain containing :

    Redirect 301 / http://www.domain.com
    

    I don't know how this can work on IIS, I highly doubt it supports .htaccess files, but my guess is that you can do this with ISAPI filters.