What is the recommended method of HTTP Redirection from multiple URLs to one URL?
-
03-10-2019 - |
Question
I have a website that has a number of URLs that people use to connect to that site (uses the bindings on the IIS website and everything works as intended):
- http://www.sample.com
- http://sample.com
- https://www.sample.com
- http://xyz.sample.com
- http://oldurl.com
Now what I want to do is have all of the URLs go to https://www.sample.com - so if you type in "http://xyz.sample.com" or "sample.com" you should go to https://www.sample.com
The question is what is the best mechanism to do this? I have one possible solution (which I will put as an answer to this question), but I get the feeling that there might be another, better solution available.
Solution
One possible option via IIS settings would be to do the following:
- Remove extra site bindings from website (i.e. xyz.sample.com, sample.com, etc...). This should leave just the web url you are trying to get all traffic to flow to (i.e. https://www.sample.com)
- Create a second website in IIS
- In the second website create bindings that were removed from the original website
- In the second website use the HTTP Redirect (option in IIS) to direct all traffic from the second site (where all the alternate urls now reside) to the goal site (https://www.sample.com)
OTHER TIPS
Set up a new website on the new binding https://www.sample.com, and then, on the old website, open the Http Redirect property page and set up your redirect.
That's in IIS Manager.