Check your web redirects and HTTP responses
Redirects with IIS (Microsoft)
IIS (Internet Information Services) is Microsoft's web server, integrated into Windows Server. It is widely used in enterprise environments and Windows hosting (.NET, ASP.NET, Azure).
Redirects are configured in a web.config file in XML format, placed at the root of the site or in the target directory. The examples below use the URL Rewrite module, which must be installed separately if needed (available free of charge from the Microsoft website).
301 (permanent) redirect with IIS
Redirect a specific page:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect old page" stopProcessing="true">
<match url="^old-page\.html$" />
<action type="Redirect" url="https://www.example.net/new-page.html" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Force HTTPS (HTTP → HTTPS):
<rule name="Redirect HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
Force www (non-www → www):
<rule name="Force www" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.net$" />
</conditions>
<action type="Redirect" url="https://www.example.net/{R:1}" redirectType="Permanent" />
</rule>
Remove www (www → non-www):
<rule name="Remove www" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.net$" />
</conditions>
<action type="Redirect" url="https://example.net/{R:1}" redirectType="Permanent" />
</rule>
302 (temporary) redirect with IIS
Same structure as a 301, with redirectType="Found":
<rule name="Temporary redirect" stopProcessing="true">
<match url="^old-page\.html$" />
<action type="Redirect" url="https://www.example.net/new-page.html" redirectType="Found" />
</rule>
Simple redirect via httpRedirect (without URL Rewrite module)
This native method redirects all requests to a single URL. Useful for a full domain migration:
<configuration>
<system.webServer>
<httpRedirect enabled="true"
destination="https://www.example.net/"
httpResponseStatus="Permanent" />
</system.webServer>
</configuration>