Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a website with multiple bindings eg

http://www.mysite.com
http://mysite.com
http://www.mysitenow.com

Using IIS, can I force requests to the second two domains to redirect to http://www.mysite.com

share|improve this question
    
Would this be better done with DNS? –  ST8Z6FR57ABE6A8RE9UF Apr 13 '11 at 4:21
add comment

3 Answers

up vote 2 down vote accepted

You need to have two sites in IIS. The first listens on port 80 and is only bound to:

http://www.mysite.com

The second also listens on port 80 but is bound to all of the urls you want redirected, i.e.:

http://mysite.com
http://www.mysitenow.com

Use the IIS redirect options within IIS to redirect all requests to the first site.

Alternatively, you can also install the Url Rewriter module from Microsoft and create an inbound rewrite rule that does this as well.

share|improve this answer
    
Sounds good but I am going to do this via code, as a developer, its easier for me! –  Petras Apr 14 '11 at 1:21
add comment

The details of how you do this through code can be found here http://www.yart.com.au/Resources/Umbraco-Tips-And-Tricks/Redirect-To-A-Base-URL.aspx

share|improve this answer
add comment

In IIS7, select the site you want the 'redirects' to occur for, select 'bindings' on the right hand side, and then just add an entry for each site you want the redirects to start from.

For example:

select "mysite.com", select bindings, and then add separate entries with hostnames of "www.mysitenow.com" and "www.mysite.com".

EDIT 1 A hacky way to do that then would be to add them as individual sites, remove any index files from their site directories, and edit the 404 error page to perform a redirect. I've actually used this crappy method to do an SSL redirect.

share|improve this answer
    
Adding a binding does not cause a redirect. See my comment below. –  Petras Apr 13 '11 at 5:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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