Different Ways to Redirect Users to New SharePoint Online Sites
My role often involves moving work from on-premises servers to Microsoft 365, or vice versa. Some processes are straightforward and well-organized. When I say well-organized, I mean they minimize the impact on end-users. Think about it – users don’t have much of an impact on mailbox migration as the process is quite seamless, but SharePoint is a different story. Today, we’ll discuss common issues and how we can address them when migrating SharePoint sites and data to SharePoint Online.
One common issue when migrating SharePoint sites to Microsoft 365 is redirecting users to the new site. There are a few approaches we can take during the migration, and we’ll explore each one and allow you to choose the best one for your specific situation.
Updating Browser’s Home Page
This isn’t a super technical migration approach. It’s more of a temporary fix to make sure users use the migrated sites. Often, companies set up policies like this to tell Edge or Chrome to open their SharePoint site. These policies are the easiest among all methods and can be done via Intune. Figure 1 shows an example of an Intune configuration profile to set Chrome and Edge’s home page.
So, here’s the thing – we’re only giving default users access to the new site, not stopping them from accessing the old one. Of course, you can update the permissions on the source site and make all users “viewers only” to prevent any changes. But that won’t stop them from accessing the old site.
Using a Redirect Page to Redirect User to a New Site
Instead of just pointing all users to the same site, we may have situations in which not all sites migrate at once or cannot support a simple site-level redirect. There are many ways to conduct the redirect and here we will explain the simplest one.
The first approach is to use the default SharePoint feature, as shown in Figure 2. All you need to do is:
- Create a news link on the site
- Set the link to redirect to the new SharePoint site
- Set that as the default page for the site
This way, SharePoint will create an ASPX file, which does nothing but redirect to the target site. When the user opens the old site, they will be redirected to the new site.
But there’s a catch with this approach. It only works if you open the site using a URL like https://server/sites/site01, not like https://server/sites/site01/page1.aspx. That’s where the next approach comes in.
Using JavaScript to Redirect
Another approach we can take to address the need for page-level redirects is to use JavaScript. This approach works for pages that can add Webpart or when it is possible to modify the master page. Note that all pages using that specific master page will get redirected if you modify the master page. The idea behind this is to add a JavaScript code using Code Snippet as shown in Figure 3, and the script will perform the following logic:
- Take the URL from the browser
- Replace the URL with the defined pattern
- Create a new URL and ask the client’s browser to redirect to the new URL
Below is a JavaScript segment we can use on a page.
<em>window.location.href = "https://company.sharepoint.com/sites/site1/" + window.location.search;</em>
You don’t need to use the exact same script. Sometimes, we may need advanced scripts, like checking if a parameter is in the query string (i.e. window.location.search property). If you want to redirect every page, you could update the master page instead of adding the above script page by page.
This issue addressed most cases, except for URLs pointing directly to documents, like https://server/sites/site_01/Shared Documents/File1.docx, which aren’t handled by the JavaScript approach since there’s no HTML page loaded. We may need to use the last approach if most URLs point directly to files.
Using a Reverse Proxy Between End User and SharePoint Sites
Most of the time, we deal with a mix of the following common uses when dealing with URLs pointing to files directly:
- Users have old documents or emails with hyperlinks to SharePoint documents using the current URL.
- In an Excel worksheet, a formula reads data from a linked Excel worksheet using the current URL.
To address this kind of URL, use a Reserve Proxy that redirects all requests to old servers. We recommend using HTTPS 301 redirects to minimize performance impact. Popular products include NGINX, Azure Application Gateway, and Traditional Load Balancers. The architect’s design is illustrated in Figure 4 below.
Make sure the reverse proxy or load balancer has the ability to process HTTP requests by URL (TCP Layer 7 capable) to inspect the URL and decide what to do. This allows controlling redirects to folders or files. For cloud-only solutions, Azure Application Gateway is recommended, with documentation included for the URL redirect setup. Alternatively, NGINX, an open-source solution used by many cloud applications, can be run on a Linux VM.
Example NGINX redirect configuration:
server { rewrite ^/sites/site1/(.*)$ https://company.sharepoint.com/sites/site1/$1 permanent; }
But this approach has a drawback: it can’t be retired as there are always embedded links in documents. To address this, set a deadline for coexistence and inform end-users on how to manually update links.
How SharePoint Online Handle Redirection
When an administrator renames a site in SharePoint Online, for instance, from https://company.sharepoint.com/sites/site1 to https://company.sharepoint.com/sites/site1_new, Microsoft renames the site and creates a new site with the old name using a redirect template. Users accessing the old site will be redirected, and the URL path must match before and after the redirect.
Focus on End-User Experience During Migration
The most crucial factor for a successful migration project is minimizing user interruption and providing a seamless experience. While technical feasibility may limit this, as consultants or IT administrators, we should strive to achieve it within affordable costs. If you have a large number of sites, I would recommend using the reverse proxy approach.
However, I usually take the migration as a chance to consolidate or rearchitect the information architecture (site structure).
If you want to better manage and minimize the risk for your SharePoint migration project, Quest Software offers an On-Demand Migration solution, which supports the migration of sites between SharePoint Server and SharePoint Online.