Suddenly, the help desk ticket queue explodes. "My bookmarks don't work!" "The link in the CEO's email is broken!" "I get a 404 error when accessing the HR portal!"
When working with enterprise websites, it is imperative for users, customers, and potential clients to be able to locate information seamlessly. Change is inevitable—companies change their structure, names, and products, and these changes eventually reach the website architecture.
If you do not handle these changes correctly, you risk frustrating your user base and destroying your SEO rankings (Search Engine Optimization). A "404 Page Not Found" error is the quickest way to lose credibility.
In this comprehensive tutorial, I will guide you through using the IIS URL Rewrite Module to manage these changes gracefully. By the end of this guide, you will be able to redirect traffic from old URLs to new ones automatically, ensuring business continuity.
Part 1: Initial Installation & Setup
Before we can configure any rules, we need to ensure the server understands how to rewrite URLs. By default, Internet Information Services (IIS) does not have this capability installed.
1. Download the Rewrite Plugin
To enable this functionality, you need the official Microsoft extension. Go to IIS.net/downloads/microsoft/url-rewrite and download the extension appropriate for your Windows Server version.
2. Install on Web Front Ends
Crucial Step: You must install this extension on every Web Front End (WFE) server in your farm. If you have a load balancer distributing traffic between Server A and Server B, but only Server A has the plugin, users will face intermittent errors depending on which server they hit.
Pro Tip: After the extension is installed, close and reopen the IIS Manager console completely to see the new "URL Rewrite" icon appear.
Part 2: Creating a Rewrite Map
We will use a feature called a "Rewrite Map." Think of this as a lookup table or a dictionary. Instead of writing a complex logic rule for every single broken link (which creates CPU overhead), we create one list of "Old URL vs. New URL" and one rule to check that list.
From within IIS Manager, expand your server node and click on the specific SharePoint site (Web Application) you wish to add the redirects to.
In the middle pane (Features View), verify you are in the IIS section and double-click the URL Rewrite icon.
Look at the Actions pane on the right-hand side. Click on the link that says View Rewrite Maps. This is located under the "Manage Providers" section.
Now, look at the Actions pane on the right again. Select Add Rewrite Map....
Enter a descriptive name for your new mapping. For this tutorial, we will call it Old SharePoint or LegacyRedirects. This name is important as we will reference it later in the rule logic.
After creating the map, it will appear in the list. Double-click on the mapping you just created to go inside it.
It's time to add our first redirection. From the Actions pane, click Add Mapping Entry....
In the pop-up window:
- Original Value: Enter the relative path of the old URL (e.g.,
/sites/OldHR). - New Value: Enter the absolute URL of the destination (e.g.,
https://portal.company.com/sites/NewHR).
Click OK.
You will now see your new entry in the list. You can add as many as you like here, but for now, let's proceed to making it work.
Once you have added your entry, look at the top of the Actions pane and click Back to Rules.
Part 3: Creating the Logic Rule
Creating the map is like writing a phone book. Now we need to tell IIS to use the phone book whenever a request comes in.
From the Actions pane on the right, click Add Rule(s)....
Under the "Inbound rules" category, select Rule with Rewrite Maps and click OK.
A dropdown will appear asking "Select the Rule Action". Select Redirect. This ensures a 301 Permanent Redirect is issued, which is essential for SEO preservation.
From the dropdown menu, select the mapping you created earlier (e.g., Old SharePoint).
After you click OK, you will see your new rule in the main list. IIS is now actively checking every incoming request against your map.
Part 4: The "Pro" Method – Bulk Editing via Web.Config
Using the visual interface is great for 5 or 10 links. But what if you have migrated a massive file server and have 500 broken links? Entering them one by one is tedious and prone to error.
Fortunately, IIS stores all this configuration in the web.config XML file. We can edit this file directly to add bulk entries.
1. Locate The Web.Config File
Navigate to the root directory of your SharePoint web application. Typically, this is found at:
2. Edit The Web.Config
Open the file in a text editor (like Notepad++ or Visual Studio Code). Search for the <rewrite> tag. It will look something like this:
3. Add Bulk Entries
You can now simply add new lines following this format:
Pro Tip: Use Microsoft Excel to generate these lines. Put old URLs in Column A, new URLs in Column B, and use a formula to concatenate them into the XML string.
Once you save the file, the changes take effect immediately. There is no need to perform an IISRESET or restart the server.
FAQ: Common Questions
No. You do not have access to IIS or the web.config in SharePoint Online. For SPO, you must use "Site Swaps" or manage redirects via PnP PowerShell or a custom solution.
IIS URL Rewrite is extremely efficient. Using a "Rewrite Map" is the most performance-friendly way to handle large numbers of redirects because it uses a hash table lookup rather than processing hundreds of individual rules.
SharePoint's internal ID-based redirection works if you move a file within the *same* site collection. However, if you are migrating across site collections or web applications, those internal links break. IIS Rewrite covers the gaps that SharePoint misses.
Conclusion
It is as simple as that. Again, by creating the redirects or rewrites, you are saving your SEO, maintaining the user experience, and preventing a lot of pesky help desk calls.
So, if you need to rename a web application, a library, or revamp the whole structure of a site, this method will keep your links working and information accessible.
Did this guide save your migration project? Let me know in the comments below!
0 Comments
Thanks!