Products SEO & GEO Agent Paid Ads Agent Website Agent Conversion Agent
How it works Pricing FAQ Blog Book a call

301 Redirects in IIS: Set Them Up on a Windows Server

Updated · 8 min read

Short answer Install Microsoft's URL Rewrite module, open your site in IIS Manager, add a Blank rule, choose the Redirect action and set the type to Permanent (301). Then test the old address with curl.exe and confirm it answers 301, not 302. IIS's simpler HTTP Redirect feature sends 302 unless you change it.

Want help applying this to your business? Talk it through on a free 30-minute call.

Book a call

How do I add a 301 redirect in IIS?

Use the URL Rewrite module. It is Microsoft's add-on for IIS (Internet Information Services, the web server built into Windows Server), and it handles one page, a list of pages or a whole domain. Google wants a permanent redirect done on the server:

"If you need to change the URL of a page as it is shown in search engine results, we recommend that you use a permanent server-side redirect whenever possible." (Google Search Central: Redirects and Google Search)

The same page says 301 and 308 both mean a page "has permanently moved to a new location". IIS gives you two ways to send one:

URL Rewrite moduleHTTP Redirect feature
Comes with IISNo, a separate downloadYes, but not installed by default
Good forSingle pages, lists of old URLs, www and https rules, domain movesSending a whole site or folder to one new place
Status codes301, 302, 303, 307. No 308301, 302, 307, and 308 on IIS 10
Default to watchCheck that Redirect type says Permanent (301)Sends 302 Found unless you change it

Sources: Microsoft Learn's URL Rewrite configuration reference and its HTTP Redirects page.

Most owners never touch IIS. If your site runs on Wix, Squarespace or Shopify, use that platform's redirect screen instead. This guide is for sites hosted on Windows, often older ASP.NET builds an agency set up. If you're unsure, ask whoever hosts the site.

Step 1: Install the URL Rewrite module

Download URL Rewrite 2.1 from Microsoft's IIS.net site. The page lists it for IIS 7, 7.5, 8, 8.5 and 10, with x86 and x64 installers in ten languages, and no price. On a current 64-bit Windows Server, pick the x64 installer, run it, then reopen IIS Manager. A URL Rewrite icon now shows in your site's Features View.

On shared Windows hosting you may not be allowed to install anything. Ask the host whether URL Rewrite is already on the server; you can still add rules in your site's web.config file.

Step 2: Add a redirect rule in IIS Manager

Microsoft's walkthrough builds a redirect rule in these steps (Microsoft Learn: Creating Rewrite Rules for the URL Rewrite Module):

  1. Open IIS Manager and select your site in the Connections pane.
  2. Double-click URL Rewrite.
  3. In the Actions pane on the right, click Add Rule(s), pick Blank rule, click OK.
  4. Name: something you'll recognize later, like "Old drain page".
  5. Pattern: the old path, written as a regular expression (a text pattern). For one page: ^services/drain-cleaning\.aspx$
  6. Action type: Redirect.
  7. Redirect URL: the new address, for example https://www.example.com/drain-cleaning/
  8. Redirect type: Permanent (301).
  9. Click Apply in the Actions pane.

IIS saves the rule in the web.config file at your site's root, inside a rewrite section. Back that file up before you edit it by hand.

Three details trip people up. The pattern sees the path without the leading slash and without anything after the question mark. Matching ignores upper and lower case unless you turn that off. And Append query string is on by default, so ?id=5 on the old URL gets added to the new one (Microsoft Learn: URL Rewrite Module Configuration Reference).

Redirecting many old URLs at once: rewrite maps

If you have 50 old pages with no shared pattern, don't write 50 rules. Use a rewrite map: a two-column list of old path and new path, read by one rule.

  1. In URL Rewrite, click View Rewrite Maps, then Add Rewrite Map, and name it, for example "OldPages".
  2. Click Add Mapping Entry for each page: original value /old-page.aspx, new value /new-page/.
  3. Add one rule that matches every URL, with a condition whose input is {OldPages:{REQUEST_URI}} and whose pattern is (.+). Set the action to Redirect, the URL to your domain plus {C:1}, and the type to Permanent.

That setup comes from Microsoft's rewrite maps walkthrough, which uses Permanent for its redirect example. The Add Rule(s) dialog also has a built-in Rule with Rewrite Map template that creates this rule for you (Microsoft Learn: Rule Templates Overview). Map keys start with a slash and include the query string, because REQUEST_URI holds both. Turn off Append query string on this rule so old parameters aren't carried over.

www, https and new-domain redirects

These rules match every path and use a condition on the host name or the HTTPS setting. A www rule, for example, matches (.*), adds a condition that the host (HTTP_HOST) does not equal www.example.com, and redirects to https://www.example.com/{R:1}. The condition is what stops a loop: without it, the new URL matches the rule again.

Copying a rule from Microsoft's documentation? Check its redirect type. The reference page's own canonical-host example and its rewrite-map example both use Found, which is a 302, not a 301.

When the HTTP Redirect feature is enough

For "send this entire old site to the new one," IIS's built-in HTTP Redirect works without the add-on. It isn't on by default: add HTTP Redirection under Web Server, Common HTTP Features in Server Manager's Add Roles and Features. Then in IIS Manager, select the site, double-click HTTP Redirect, check the redirect box, enter the destination, set the status code to 301 Permanent, and click Apply (Microsoft Learn: HTTP Redirects).

Microsoft's reference states its default plainly: httpResponseStatus "The default is Found", the 302 code. Leave it untouched and your permanent move goes out as temporary.

How do I test an IIS 301 redirect?

Check the status code, not just where the browser lands. A 302 lands in the same place.

  1. curl.exe. Microsoft says curl is included with Windows. Open PowerShell and run curl.exe -I followed by the old URL. The first line should say 301 and the Location line should show the new URL. Type curl.exe, not curl: in Windows PowerShell 5.1, curl is an alias for a different command (Microsoft Learn: curl on Windows).
  2. Chrome DevTools. Open the Network panel and tick Preserve log, which keeps requests across page loads, and Disable cache (Chrome DevTools: Network features reference). Load the old URL and read the Status column.
  3. Chains. Make sure the old URL goes straight to the final page. Google says Googlebot "can follow up to 10 hops" but advises "redirecting to the final destination directly" (Google Search Central: Site moves with URL changes). The same guide says to change your own internal links to the new URLs, so nobody passes through the redirect at all.

Test in curl or with the cache off for a reason. The HTTP standard says "A 301 response is heuristically cacheable" (RFC 9110), so a browser may remember an old, wrong redirect after you fix it.

Common IIS redirect errors and fixes

What you seeWhyFix
Status 302 instead of 301HTTP Redirect defaults to Found; copied sample rules use FoundSet Permanent (301) and test again
HTTP Error 500.19, code 0x8007000dweb.config has a rewrite section but URL Rewrite isn't installed, or the XML has a typoInstall the module, or fix the line the error names
HTTP Error 500.19, code 0x80070021The section is locked at the server levelAsk the server admin or host to unlock it
The rule never firesPattern starts with a slash or includes ?id=Drop the slash; match query strings with a condition or a rewrite map
"Too many redirects" in the browserA site-wide rule matches its own destinationAdd a host or HTTPS condition so the new URL doesn't match
Old parameters tacked onto the new URLAppend query string is on by defaultUntick it on that rule
A fixed redirect still goes to the old placeYour browser cached the earlier 301Test with curl.exe or Disable cache

The 500.19 causes come from Microsoft's troubleshooting page, which lists a missing URL Rewrite module as a typical cause of "malformed or unrecognized XML elements" (Microsoft Learn: Fix HTTP Error 500.19).

Example

A law firm renames 40 old .aspx pages

The firm's new site uses clean addresses. Its developer builds a rewrite map with 40 entries, one rule set to Permanent, and Append query string off. A curl.exe check on all 40 old URLs shows 301 and a single hop each.

A dental office moves to a new domain

The whole old site goes to the new domain, page for page. One URL Rewrite rule on the old site matches (.*) and redirects to the new domain plus {R:1}, Permanent. Because it's a domain change, the office also uses Search Console's Change of Address tool, which Google says is only needed when moving between domains or subdomains.

A contractor's redirect "works" but shows 302

The redirect was made with HTTP Redirect, left on its default. Changing the status code to 301 Permanent and clicking Apply fixes it. Visitors saw no difference; Google now gets the permanent signal.

FAQ

Is a 301 or a 308 better for SEO?

Google treats both as permanent. The difference is technical: per RFC 9110, a browser may turn a form POST into a GET after a 301, while 308 keeps the POST. For normal pages, a 301 from URL Rewrite is fine.

How long should I keep IIS redirects in place?

Google's site-move guide says to keep them "for as long as possible, generally at least 1 year".

Can I redirect every old page to the home page?

Google advises against it: sending many old URLs to one unrelated page "might be treated as a soft 404 error". Point each old page to its closest new match.

Do redirects in web.config work on Azure or shared Windows hosting?

Microsoft's walkthrough says URL Rewrite comes pre-installed on Azure's Windows web hosting (then called Windows Azure Web Sites), and rules go in web.config the same way. On other shared hosts it depends on what the host installed, so ask them.

Different for you?

Keep learning

NextSite navigation and SEO: how your menu affects Google rankingsHow your website menu affects SEO: how Google finds pages through it, which pages it treats as important, what passes link value, and what doesn't count.

Do it yourself

Crawlability checklist: make every page reachable by GoogleA crawlability checklist for a small business site: find orphan pages, robots.txt blocks, broken links, redirect chains and server errors, with free tools.

Ask us one question

One line is enough. We reply by email.

Sources

  1. IIS.net: URL Rewrite 2.1 download
  2. Microsoft Learn: Creating Rewrite Rules for the URL Rewrite Module
  3. Microsoft Learn: URL Rewrite Module Configuration Reference
  4. Microsoft Learn: Using Rewrite Maps in URL Rewrite Module
  5. Microsoft Learn: Rule Templates Overview
  6. Microsoft Learn: HTTP Redirects (httpRedirect)
  7. Microsoft Learn: Fix HTTP Error 500.19 in IIS Configuration Files
  8. Microsoft Learn: curl on Windows
  9. Google Search Central: Redirects and Google Search
  10. Google Search Central: Site moves with URL changes
  11. Chrome DevTools: Network features reference
  12. RFC 9110: HTTP Semantics (301 and 308)