Recently we have received the request from client that they are are going for brand conversion, i.e they want to move from their current website http://www.oldwebsite.com to the new website http://www.newwebsite.com
They want all the request to be redirected from old website to the new website with the entire URL for eg: they wanted to take care of the below conversion
eg:
If the user is Visiting
http://www.oldwebsite.com/Link1/Link2/Link3 it should be automatically redirected to the new website
http://www.newwebsite.com/Link1/Link2/Link3
IIS Changes
it can be easily achieved by leveraging the Existing IIS functionality – URL-Rewrite module.
by default, IIS doesn’t have this functionality. You have to install this extension from this URL https://www.iis.net/downloads/microsoft/url-rewrite.
After installing this module, You can verify this installation in IIS , make Sure URL Rewrite Module is appearing.
- add the below code inside the web.config , Inside the <System.WebServer> tag<rewrite>
<rules>
<rule name=”TestRedirect” stopProcessing=”true”>
<conditions logicalGrouping=”MatchAny” trackAllCaptures=”false”>
<add input=”{HTTP_HOST}” pattern=”www\.oldwebsite\.com” />
<add input=”{HTTP_HOST}” pattern=”oldwebsite\.com” />
</conditions>
<action type=”Redirect” url=”http://www.newwebsite.com/{R:1}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>this above rule will take care of automatic redirection your website request from oldwebsite.com to newwebsite.comSitecore Changes - App_Config/Include/UrlResolver.config – CM & CD
- App_Config\Include\SitemapXML.config – CM
- Sitemap.xml – Regenerate SiteMap
- Robot.txt
- URLResolver.config – CM & CD
inside the App_Config/Include/UrlResolver.config add your newwesbsite.com as like below
<setting name=”SitecoreModule.UrlResolver.ExcludedRedirects” value=”localhost,www.oldwebsite.com,www.newwebsite.com” />
<setting name=”SitecoreModule.UrlResolver.ForceWWW” value=”www.oldwebsite.com,www.newwebsite.com” />
the above changes are applicable to both CM and CD.
SitemapXML.Config – CM(Content Management)
Inside App_Config\Include\SitemapXML.config
<site name=”website” filename=”sitemap.xml” serverUrl=”www.newwebsite.com” />
Sitemap.xml
Your current sitemap http://www.oldwebsite.com/sitemap.xml is generated with the all your oldwebsite.com links, you have to regenerate the sitemap.xml to generate all the links with the newwebsite.com
Robots.txt
Update robots.txt to use the newwebsite.com/sitemap.xml , So that Search Engine will start crawling the new website links
Sitemap: http://www.newwebsite.com/sitemap.xml
Sitecore Content & Design Changes
Before doing all the above changes, Take the copy of production DB and restore into staging environment, Do all the content changes and during the production roll restore the Staging Database into production and replace the necessary Styles and images changes _CSS and _Images folder