Introduction
These days, I typically use something like cloudflare to deal with redirecting one site to another – but sometimes a client is not using a DNS provider, where that is possible – and I have to turn back to good old IIS to get the job done.
What do we want to accomplish?
- Any request to a site should result in redirection to another site
- Redirect should be permanent (http status code 301)
- We need to use IIS to do it
Solution 1 – Using IIS Manager
- Create a site and configure bindings, so it responds to the domain, port etc, that you want to redirect FROM (outside the scope of this post)
- Add a page rule by clicking your site => URL Rewrite
- Configure the rewrite rule like this:This rule basically contains…:
– match ANY url that hits this website
– redirect it to the redirect url
Solution 2 – using web.config
If you don’t want to use the IIS manager, you can just drop a web.config into the redirect site like this:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to another site" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <action type="Redirect" url="http://sixfootfour.net" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Comments are closed.