Redirect your sites in SharePoint to a new site collection


During a intranet migration there was a requirement to move the intranet from the root site to a site collection under "/sites". When moving site collections around in the SharePoint Admin Center a redirect will automatically be added to the old URL, so in many cases this is sufficient.

In this case we could use this approach, as you only can swap at not move away from the root site.


I modern sites the solution to add a redirect to the root site actually was much easier than one would anticipate.

  1. Go to the site you want to redirect away from, and from the front page select New and News link
  2. Add the full URL to the site and a title like Redirect
  3. Go to the Site Pages library at /SitesPages, ex.
  4. Mark the newly created News link as the homepage of the site by selecting ... and Make homepage

When you now visit this site you will be redirected to the new site specified in the redirect link.

Tip: If you need to remove or change the redirect, add "?stay=true" to the end of the URL. Example:

Redirect classic sites

If your migration also includes moving away from a classic publishing site to a modern communication site, you will face issues since the old URL pointed the users to the Pages/Default.aspx (or a similar folder if using other default languages).

A workaround could be to create a classic site pages library in the modern site named Pages and add a landing page informing the users of the new site address. Note that this only work on modern team sites, not for communication sites.

Using the PnP.PowerShell ( module:

Connect-PnPOnline -Url
New-PnPList -Title Pages -Template WebPageLibrary

Then go to the newly created library and add a page named Default. In this page you could add some information informing the end-users that the site has moved.

It is also possible to add a redirect using JavaScript like this example:

function corpRedirectPage() { 
	var urlParams = new URLSearchParams(;
	var stay = urlParams.get('stay');
	if (stay === 'true') { 
	window.setTimeout(function() { 
		window.location.href = ''; 
	}, 1500); 


If you need to remove or change the redirect, add "?stay=true" to the end of the URL. Example:

Note: Using JavaScript is most likely blocked on the site due to the new default policies. This can be changed temporarily before adding the script to the page:

# Enable custom scripts
Set-PnPSite -Identity -DenyAndAddCustomizePages:$false

# Add script to page

# Disable custom scripts
Set-PnPSite -Identity -DenyAndAddCustomizePages:$true