Leveraging Redirects Over Rewrites For Sharepoint Url Management

The Problem of Broken Links from URL Changes

One of the most common issues that arises when making changes to SharePoint site structures and URLs is the dreaded “404 – Page Not Found” error. Users who have bookmarked old URLs or have links from various sources suddenly find themselves facing broken links rather than the content they were expecting.

This frustrates users and disrupts productivity. It also creates extra work for SharePoint administrators who must track down all outdated references and update them to the new URLs.

While care can be taken to minimize link breakage when renaming or moving pages and sites within a SharePoint environment, some disruption is often unavoidable. When URLs change, a redirection strategy is crucial to preserve access to content.

Understanding Redirects

A redirect is an instruction that routes requests for one URL to a different destination URL. When users click on links to older, changed SharePoint URLs, the redirect tells the server to send them to the current URL instead.

This redirection happens behind the scenes, so the end user is simply taken directly to the expected content at the new location. The only indication that anything different occurred is the updated URL in the browser address bar.

By implementing redirects to preserve old SharePoint URLs, administrators can ensure continued access to content even after substantial changes to the SharePoint infrastructure. Users can keep using the same links they have always used without disruption.

Implementing Redirects in SharePoint

SharePoint provides flexible options for setting up both temporary and permanent redirects when URLs are changed or sites are reorganized. Redirects can be implemented both at the individual site level through SharePoint Designer, or across an entire SharePoint environment through IIS web.config settings.

The specific redirect setup process will vary depending on the scale of the URL changes:

  • For small site changes, individual redirects can be created through SharePoint Designer by mapping old and new URLs.
  • For widespread URL changes across subsites and site collections, IIS web.config modifications allow redirects to be implemented more comprehensively.

Proper analysis of link references combined with strategic redirect implementation can virtually eliminate broken links during or after SharePoint URL updates.

Redirect Methods in SharePoint

301 Permanent Redirects

A 301 redirect designates that a page has permanently moved to a new location. Search engines and other automated tools will update their indexes to point to the new URL for a 301 redirected page.

301 redirects are optimal for most typical SharePoint URL updates like:

  • Site migrations to new domains
  • Consolidation of multiple old sites into one new site
  • Permanent renaming of pages or sites

By returning the 301 status code, SharePoint signals both users and crawlers that the new redirect target is now considered the canonical location for the content.

302 Temporary Redirects

A 302 redirect is used for more short-term or temporary URL changes in SharePoint. The 302 status tells automated tools not to update their indexes, since the redirect may change again in the future.

Some scenarios where a 302 redirect would be effective include:

  • Restructuring sites while in a site development or staging environment
  • URL changes that may need to be rolled back quickly
  • Sites that need to be taken offline temporarily

302s allow redirects to be implemented without search engine penalty. The temporary redirects will seamlessly guide users to the correct pages while changes are still in flux.

Example Code for 301 Redirects

The most comprehensive way to implement 301 redirects for SharePoint URL changes is by adding rewrite rules to the web.config file. This will apply redirects globally across all sites and subsites.

The following web.config code shows an example redirect rule using a regular expression pattern to match old URLs, and rewriting them to new locations:

<rewrite>
  <rules>
    <rule name="Redirect Old URL" stopProcessing="true"> 
      <match url="^sites/oldsite/(.*)$" />
      <action type="Redirect" redirectType="Permanent" url="https://domain.sharepoint.com/sites/newsite/{R:1}" />
    </rule>
  </rules>
</rewrite>  

This will redirect all traffic from the oldsite SharePoint site to the same pages under the newsite location. The {R:1} variable pulls the matching content path from the old URL to construct the new target URL.

Multiple redirect rules can be stacked to address a variety of historical SharePoint URLs that may need preservation after site changes.

Optimizing Redirect Performance

While redirects are invaluable for maintaining working links after SharePoint URL updates, a redirect does add extra processing time compared to direct page requests. As more rules and hops get introduced, the incremental latency can impact site performance.

There are a few key ways to optimize SharePoint redirect configurations for efficiency:

  • Set logical redirect paths – Design rules to minimize long chains of redirects
  • Implement targeted redirects – Only preserve necessary historical URLs to limit scope
  • Revisit old redirects – Remove unnecessary rules for sites or pages that have fallen out of use
  • Utilize caching – Caching frequently redirected URLs can improve redirect speed

Keeping SharePoint redirect rules lean and efficient will allow all those valuable redirects to guide users without slowing things down.

Redirect Considerations and Best Practices

Below are some key best practices to follow when implementing redirects for SharePoint URL management:

  • Audit link references before changes – Use link reporting to see the full scope of external and internal references to updated pages.
  • Stagger complex changes – Break extensive site restructuring into multiple smaller batches when possible.
  • Use permanent vs temporary selectively – Permanent redirects should be used for most typical site changes. Use temporary only for short-term or unfinished changes.
  • Include redirect testing in validation – Test that redirects are working from real internal and external linking sources after go-live.
  • Set reminders to revisit old redirects – Occasionally review if preserved links are still needed or can be removed from the rules.

Planning redirect strategy along with site change planning will lead to the smoothest possible SharePoint URL transition.

The Benefits of Redirects Over Rewrites

URL rewriting refers to dynamically displaying one SharePoint URL to users while internally still loading a different target page. This method can also preserve working links, but has some downsides vs. utilizing redirects:

  • Rewrites require custom development vs out-of-the-box redirects
  • Rewrites hide actual site structure changes from users
  • Rewrites fail to signal permanent URL changes to search engines

In most cases where legacy SharePoint URLs need to be preserved, standard redirects provide a simpler and more transparent solution. The specific status codes clearly convey the nature of URL changes, while seamlessly guiding users and crawlers.

Development effort can be minimized by using native IIS URL Rewrite capabilities rather than custom code. This also follows SharePoint best practice patterns and ensures maximum compatibility.

For managing updates to SharePoint site structures over time, leveraging redirects over custom URL rewriting will typically yield the best balance of link preservation, transparency, and low overhead.

Leave a Reply

Your email address will not be published. Required fields are marked *