IIS (Internet Information Services) · Performance & Behaviour

HTTP Redirect

The HTTP Redirect feature sends all requests for a site or folder to a new address — perfect for moved domains.

Advanced 5 min Lesson 25 of 33Covers IIS 10 on Windows Server 2019/2022/2025 and Windows 10/11.
Before you start:URL Rewrite
0/33 in IIS
On this page · 5 min · Advanced

In simple words#

HTTP Redirect is a “We have moved” sign on the old shop door that sends every visitor to the new address. URL Rewrite is the smarter assistant who can redirect only certain visitors based on rules.

301 / 308
Permanent redirect (308 keeps the method).
302 / 307
Temporary redirect (307 keeps the method).
Exact destination
Send everyone to one URL, ignoring the path.

Learning objectives#

  • Install and use HTTP Redirect
  • Redirect a whole old domain
  • Choose the right status code
  • Know when URL Rewrite is better

Explanation#

Install the HTTP Redirection role service (Web-Http-Redirect).

httpRedirect destination sets where to go. By default the requested path is appended; exactDestination="true" sends everyone to one URL.

childOnly="true" redirects only requests for content under the folder, not the folder itself.

For conditional or pattern-based redirects (www → apex, old URLs), use URL Rewrite instead.

Code example: Move an old domain to a new one#

XMLweb.config (old-site) Illustrative
<configuration>
  <system.webServer>
    <httpRedirect enabled="true"
                  destination="https://techiebabaji.com"
                  exactDestination="false"
                  httpResponseStatus="Permanent" />
  </system.webServer>
</configuration>
Expected output
https://old-brand.example/tutorials/react  → 301 → https://techiebabaji.com/tutorials/react
https://old-brand.example/                 → 301 → https://techiebabaji.com/

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. The old site’s web.config enables redirection.
  2. The path is preserved because exactDestination is false.
  3. Permanent = 301, so search engines move rankings.
  4. The new site serves the content.

Real-world use case#

After a rebrand, the old domain keeps working: every old link lands on the same page of the new domain.

Common mistakes#

Temporary redirects for permanent moves

Search engines keep the old URLs. Use Permanent (301).

Redirect inherited by child folders unexpectedly

Child apps inherit httpRedirect. Disable it in children that should not redirect.

Best practices#

  • 301 for domain moves
  • Preserve paths
  • Keep the old domain and certificate active for months
  • Use URL Rewrite for conditional rules

Remember this#

HTTP Redirect = whole site/folder.

URL Rewrite = conditional rules.

Moved for good → 301.

Practice exercise#

Your task: Send every request to a single maintenance page temporarily.

Show solution
XML Illustrative
<httpRedirect enabled="true" destination="https://status.example.com/maintenance" exactDestination="true" httpResponseStatus="Temporary" />

Mini quiz#

HTTP Redirect quizMultiple choice Question 1 of 1

Which status should be used when a domain has moved for good?

Score so far: 0/0

Want more? Practise all IIS MCQs · IIS interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.