allBlogsList

How to change Website Domain Name in Sitecore 9.2

> Matters facts, changing the Sitecore website domain after install, it’s not as simple as it uses to be — changing the IIS website name, physical file, and hostname in the hosts file.


I was working on a project where I had to install a new Sitecore vanilla instance for a client. However, by that time that I was installing Sitecore, I didn’t have any information that guides me through the configuration, principally the hostname or instance name. As we always do, I decide to follow the default naming and convention pattern

CompanyName.dev.local.

  • Later on, the client presents me with the hostname that I should use for the Sitecore website — brand-local.companyName.com.
  • Matters facts, changing the Sitecore website domain after install, it’s not as simple as it uses to be — changing the IIS website name, physical file, and hostname in the hosts file.

Well, I will not cover in this blog the issue that I faced after trying to change the hostname given that if you follow up all the steps correctly, you will not be running into any problem.

Step 1: Stop the IIS and change the IIS site name to the new hostname — brand-local.companyName.com.

Step 2: Change the website name on the physical folder, for an example: '''C:\inetpub\wwwroot\CompanyName.dev.local to C:\inetpub\wwwroot\brand-local.companyName.com. ''' Then, you change the IIS Site to point to this new folder though Site Advances Settings.

Step 3: Add new hostname (brand-local.companyName.com) to the host file in C:\Windows\System32\drivers\etc\hosts.

Step 4: Create New Self-Certificate to be added to the new Site after changing the host. Copy the code below and save it on file with ps1 extension, as an example SelfCertificate.ps1. Then Open the Windows PowerShell as Administrator to run the SelfCertificate.ps1 to generate a new self-Certificate.

_$cert = New-SelfSignedCertificate -certstorelocation cert:\\localmachine\\my -dnsname **brand-local.companyName.com**_

_$pwd = ConvertTo-SecureString -String ‘**{Type here a Password}**’ -Force -AsPlainText_

_$path = ‘cert:\\localMachine\\my\\’ + $cert.thumbprint_

_Export-PfxCertificate -cert $path -FilePath c:\\**{WhereToSaveSelfCertificate}**\\SelfSignedCertificate.pfx -Password $pwd_

After running the script above and generate the self-certificate, you must import int into Trusted Root Certification Authorities by open mmc application. To open the mmc application, enter the mmc on Windows start search box. Now, the certificate will become available to add an https binding to your IIS host website.

Step 5: Navigate to your IIS website and use the certificate you just generated based on the new domain name. Select Site brand-local.companyName.com and then click on bindings to add the SSL certificate to the host.

Step 6: To Identity Server to recognize your new domain as a client and authenticate users, you will need to update the following file on your Identity server site.

Navigate to the following file — CompanyName.dev.local\Config\production\Sitecore.IdentityServer.Host.xml and updates the base URL for PasswordRecoveryUrl and AllowedCorsOriginsGroup1 to have the new domain.

_<AccountOptions>_  
_<PasswordRecoveryUrl>_[_https://_](https://xcnine93.dev.local/sitecore/login?rc=1)**_brand-local.companyName.com_**[_/sitecore/login?rc=1_](https://xcnine93.dev.local/sitecore/login?rc=1)_</PasswordRecoveryUrl>_  
_</AccountOptions>_

<AllowedCorsOrigins>  
<AllowedCorsOriginsGroup1>**_brand-local.companyName.com_**</AllowedCorsOriginsGroup1>  
</AllowedCorsOrigins>

Step 7: As the final step, let’s ensure that everything is working after all the updates. So, navigate to https://www.brand-local.companyName.com/sitecore/login, and it should redirect you to the Identity Server. After authenticating successfully, bring you back to Sitecore.