If your company redesigns its website and changes the underlying technology from classic ASP (about.asp) to modern PHP or .NET Core (about-us), all of your old URLs will suddenly break. Anyone clicking a link from an old email, a Google search result, or a saved bookmark will hit a 404 Not Found error. This destroys your SEO rankings and frustrates users. To fix this on a Windows Server running Internet Information Services (IIS), you do not write complex code in your application; you intercept the traffic at the web server level using the URL Rewrite module.
What is URL Rewrite?
URL Rewrite acts like a bouncer at the front door of your web server. Before your actual website ever sees a visitor’s request, the module analyzes the URL they typed. If the URL matches a specific pattern (a Regular Expression), the module instantly changes the request and forwards it to the correct, modern page, completely invisibly to the user.
Step 1: Install the URL Rewrite Module
Unlike Apache (which has mod_rewrite built-in), Microsoft IIS does not include URL Rewrite natively. You must download it separately.
- Open a browser on your Windows Server (or download it on your desktop and transfer it).
- Search for “IIS URL Rewrite Module” and download the installer from the official Microsoft IIS.net website.
- Run the installer. It requires no configuration, but you must close and reopen the IIS Manager console for the icon to appear.
Step 2: Create a Basic 301 Redirect Rule
The most common use case is forcing all traffic from HTTP to HTTPS, or forcing all traffic from domain.com to www.domain.com. We will configure a rule to redirect an old page to a new page.
- Open Internet Information Services (IIS) Manager.
- In the left pane, click on your specific website (e.g., “Default Web Site”).
- In the middle pane, double-click the URL Rewrite icon.
- In the right pane under Actions, click Add Rule(s)…
- Choose Blank rule under the Inbound rules section and click OK.
Step 3: Configure the Pattern Matching
Now we define exactly what URL we are looking for.
- Name: Give it a descriptive name like “Redirect Old About Page”.
- Requested URL:
Matches the Pattern - Using:
Regular Expressions - Pattern: Type
^about\.asp$- Explanation: The
^means the start of the string, the$means the end. The\escapes the period. This ensures it only matches exactly “about.asp” and not “about.asp/extra”.
- Explanation: The
- Ignore case: Keep this checked (Windows is usually case-insensitive, but web URLs can be tricky).
Step 4: Define the Action
Once IIS catches a user trying to access about.asp, what should it do?
- Scroll down to the Action pane.
- Action type: Change this from “Rewrite” to Redirect.
- Rewrite changes the URL secretly on the server. The user’s browser still says
about.asp, but they see the new content. - Redirect forces the user’s browser to physically load the new URL, updating the address bar and telling Google to update its search index.
- Rewrite changes the URL secretly on the server. The user’s browser still says
- Redirect URL: Type
/about-us. - Redirect type: Select Permanent (301). This is critical for SEO.
- Click Apply in the top-right Action pane.
Step 5: The web.config File
When you click Apply, IIS does not save this rule in a hidden Windows registry key. It actually writes raw XML directly into your website’s web.config file located in the root directory of your site (e.g., C:\inetpub\wwwroot\web.config).
If you open that file in Notepad, you will see a new <rewrite> block.
<rewrite>
<rules>
<rule name="Redirect Old About Page" stopProcessing="true">
<match url="^about\.asp$" />
<action type="Redirect" url="/about-us" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
This is incredibly powerful because it means your rewrite rules are portable. If you migrate your website to a new Windows Server, simply copying the web.config file brings all your complex URL routing logic with it instantly.