How to change site URL in SharePoint online?

How to change site URL in SharePoint online?

No comments

 19,107 total views,  84 views today

Earlier while were working in SharePoint on-premise, it was almost impossible to think about changing the site URL after creating the site – we used to say we can rename the site title but not the site URL. These days SharePoint has gone thru lots of revolutionary changes and Microsoft has made SharePoint professionals life much easier, changing or renaming the site URL is one of them – now, we should not be worried about the site URL, if your site URL does not fit with your requirement, you have the flexibility to rename or change the site URL. Here, in this article, we will learn how to change or rename the SharePoint site URL using the PowerShell script and modern SharePoint admin center UI.

Key-Highlights: What you learn from this tutorial

  • Change a site address in the new SharePoint admin center
  • Change SharePoint Online site address using PowerShell
  • What are the effects of changing a site address in SharePoint Online?

Change a site address in the new SharePoint admin center

Login to the SharePoint admin center site using the below format URL:

https//yourtenant-admin.sharepoint.com

Example: https://globalsharepoint2020-admin.sharepoint.com

 

Click on the “Active sites” link from the left side panel.

Select the site for which you want to edit the URL.

Double click on the site title link as shown in step 2.

Change a site address in the new SharePoint admin center
Change a site address in the new SharePoint admin center

Then a site configuration modal page will be opened on the right-hand side, from there click on the “Edit” link under the URL tab (shown in step 3).

Then the “Edit URL” page will be opened.

Edit URL in SharePoint Online from SharePoint admin center
Edit URL in SharePoint Online from the SharePoint admin center

Type the new URL name in the site address box.

Then it will validate the new site address whether the site address is available or not.

Site renaming validation while editing the site URL in SharePoint Online
Site renaming validation while editing the site URL in SharePoint Online

Once we see the “The site address is available.” green message, click on the “Save” button.

The site address is available validation message and click on the save button
The site address is available validation message and clicks on the Save button

Then, we will see the “Change site name? – Do you also want to enter a new site name?” confirmation message.

Change site name - Do you also want to enter a new site name?
Change site name – Do you also want to enter a new site name?

Click on the “Yes” button

Then click on the “Cancel” or cross button as shown below:

Edit Site Name confirmation message closed
Edit Site Name confirmation message closed

Now we could see that the site URL has been updated as highlighted below.

Edit URL in SharePoint Online from SharePoint admin center verification
Edit URL in SharePoint Online from SharePoint admin center verification

That’s it, done 🙂

Change SharePoint Online site address using PowerShell

Now we will learn how we can change the  SharePoint Online site URL using PowerShell, the above steps what we have done in order to change the site address in SharePoint Online using the SharePoint admin center, we can do the same here using the PowerShell script.


####The below script will change the existing site URL to a new URL.

cls

$PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue
if($PSshell -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$fileName = "Change_SPO_Site_URL"

#'yyyyMMddhhmm yyyyMMdd
$enddate = (Get-Date).tostring("yyyyMMddhhmmss")
#$filename = $enddate + '_VMReport.doc'
$logFileName = $fileName +"_"+ $enddate+"_Log.txt"
$invocation = (Get-Variable MyInvocation).Value
$directoryPath = Split-Path $invocation.MyCommand.Path

$directoryPathForLog=$directoryPath+"\"+"LogFiles"
if(!(Test-Path -path $directoryPathForLog))
{
New-Item -ItemType directory -Path $directoryPathForLog
#Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
#$logPath = $directoryPath + "\" + $logFileName

$logPath = $directoryPathForLog + "\" + $logFileName

$isLogFileCreated = $False

function Write-Log([string]$logMsg)
{
if(!$isLogFileCreated){
Write-Host "Creating Log File..."
if(!(Test-Path -path $directoryPath))
{
Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
else
{
$script:isLogFileCreated = $True
Write-Host "Log File ($logFileName) Created..."
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
else
{
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}

########################Rename SharePoint Online site URL using the PowerShell script##############################

#Paramaters area
$adminSiteURL="https://globalsharepoint2020-admin.sharepoint.com" #Your SPO Admin center URL
$OldSiteURL="https://globalsharepoint2020.sharepoint.com/sites/TestCommSite2Modified" #Old Site URL
$NewSiteURL="https://globalsharepoint2020.sharepoint.com/sites/TestModifiedURLUsingPS" #New Site URL
$userName = "YourSPOUser@globalsharepoint2020.onmicrosoft.com" #Your SPO username
$passWord = "YourSPOPassword"
$encPassWord = convertto-securestring -String $passWord -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord
#Paramaters area - Ends

Try
{
Connect-SPOService -Url $adminSiteURL -Credential $cred

################Validating site URL renaming using the PowerShell command ##############

Write-host -f Yellow "Validating site URL renaming: "$NewSiteURL

$validationStatus=Start-SPOSiteRename -Identity $OldSiteURL -NewSiteUrl $NewSiteURL -ValidationOnly

Write-host -f Green "Validated site URL renaming: "$NewSiteURL

################Validating site URL renaming using the PowerShell command - ends here ####


############Changing site URL using the PowerShell command#######################

if ($validationStatus.ValidationState -eq "Success")
{
Write-host -f Yellow "Site URL renaming started in: "$OldSiteURL

Start-SPOSiteRename -Identity $OldSiteURL -NewSiteUrl $NewSiteURL

Write-host -f Green "Successfully site URL has been renamed, the new URL is: "$NewSiteURL
}

############Changing site URL using the PowerShell command - ends here#############

}
Catch
{

$ErrorMessage = $_.Exception.Message +"in renaming the Sharepoint Online site URL!:"
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage

}

########################Rename SharePoint Online site URL using the PowerShell script - Ends here ##############################

Prerequisites to execute the above script:

  • The user account who is executing the script should either global admin or SharePoint admin.

What are the effects of changing a site address in SharePoint Online?

Well, till now we have learned how to edit or rename site URL both using the SharePoint admin center and PowerShell script, however, there are some adverse impacts on this process, we need to take care of those. Below we will discuss those effects of changing a site address.

Apps

If apps in your organization refer to the site’s URL, you might need to republish the apps when you change the site’s address.

Custom Forms Created in PowerApps

We need to recreate the custom form in PowerApps after the site address change.

Hub sites

If the site is associated with a hub, it will need to be reassociated after the site address is changed.

InfoPath forms

InfoPath forms that refer to URLs might not work after the site address is changed, we need to update the Infopath form or data connection URL as well.

List View web part

If a List View web part is added to a page and scoped to a specific folder in that list, the web part might display an error after the site URL is changed. To fix this issue, either edit the web part and reset the folder path or remove the web part from the page and then add it again.

Microsoft Forms

If the site is a Microsoft 365 group-connected site that has forms in Microsoft Forms, any File Upload questions in forms will break. To fix this issue, recreate the file upload questions to allow responders to upload files again.

OneNote

If users have a notebook open during the site address change, they’ll see a notebook sync error.

Permissions

People who have permission to access the site can access the site during and after the site address change.

Power Apps

We need to reconnect the app or apps to your data source in PowerApps.

Power Automate

Power Automate (Microsoft Flows) will need to be recreated after the site address change – if that site was referred to in the flow connection.

Recent lists inside Office apps

The Word, Excel, and PowerPoint desktop apps and apps for the web will show the new URL after the change.

SharePoint mobile apps for Android and iOS

The SharePoint mobile apps will detect the site’s new URL. Make sure that users have updated their apps to the latest version.

SharePoint workflow 2013

SharePoint workflow 2013 will need to be republished after the site address is changed, in case the site had SharePoint 2013 workflow.

Sharing links

After the site address is changed, sharing links will automatically redirect to the new URL.

Teams (for Microsoft 365 group-connected sites)

When the site address change is complete, users will be able to access their SharePoint files in the Teams app.

Synced locations

The OneDrive sync app will automatically detect and seamlessly transfer syncing to the new site URL after the site address has been changed.

Summary: What we had here?

Thus, in this article, we have learned the below with respect to changing the site URL in SharePoint Online:

  • How to change or edit the site URL in SharePoint Online using modern admin center.
  • How to change or edit the site URL in SharePoint Online using PowerShell script.
  • What are the effects of changing a site address in SharePoint Online?

See Also:

You may also like the following SharePoint PowerShell tutorials:

Hope you have enjoyed reading this article and helped you. If you like to appreciate our efforts, please do share this with your friends and colleagues. 🙂

Download SharePoint Online & Office 365 Administration eBook

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:



Buy SharePoint Online & Office 365 Administration eBook


 

Get the free demo PDF eBook from here:

FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.