fbpx

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

  1. 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)
  2. Add a page rule by clicking your site => URL Rewrite
  3. 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>
Author

I love software development and entrepreneurship. I am Danish but live in Malta. When I am not busy taking picture of street-cats, I run my own software development company Liberatum Solutions.

Comments are closed.