I have different websites (more than 300) www.ca1.com, www.ca2.com. I would like bind all these sites to my main site - www.myMainsite.com programmatically. Can you help me in solving this. thanks.

Original post: https://stackoverflow.com/questions/8007548/binding-different-dns-to-one-dns-iis-7-programmatically/8007942#8007942


If you'd like, you can leverage PowerShell's Set-WebConfiguration interface to configure a defined system.webserver object, will handle the task of configuring URL Redirection for that defined object:


  • \sites\Default Web Site is your site.
  • domain.com is your destination

    Set-WebConfiguration system.webServer/httpRedirect "IIS:\sites\Default Web Site" -Value @{enabled="true";destination="domain.com";exactDestination="true";httpResponseStatus="Permanent"}

I'm sure there are further interfaces to the IIS config, but this is likely the easiest one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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