HTTP Redirect
The HTTP Redirect feature sends all requests for a site or folder to a new address — perfect for moved domains.
On this page · 5 min · Advanced
On this page
- In simple words
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Oct 30, 2026
Related tutorials
Interview questions
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#
<configuration>
<system.webServer>
<httpRedirect enabled="true"
destination="https://techiebabaji.com"
exactDestination="false"
httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
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#
- The old site’s web.config enables redirection.
- The path is preserved because exactDestination is false.
- Permanent = 301, so search engines move rankings.
- 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#
Search engines keep the old URLs. Use Permanent (301).
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
<httpRedirect enabled="true" destination="https://status.example.com/maintenance" exactDestination="true" httpResponseStatus="Temporary" />
Mini quiz#
Which status should be used when a domain has moved for good?
Want more? Practise all IIS MCQs · IIS interview questions
My notes#
Saved in this browser.