The editors at the company where I work have been working on a new content tree in Sitecore. First we cloned the Home-node to a NewHome node. This way they could rearrange the structure without changing the pulished one. Still they got updates that were applied to the Home node. When we went live with the new structure we wanted all the old search indexed pages to be redirected to the new page in the new structure. This is how we did it!
Working with clones might not have been the best alternative. When we deleted the key to the original item, we lost a lot of content on the clone because we were using Language Fallback. Maybe we would have saved some time just copying the present Home content node. To be able to disconnect the clones I wrote this Powershell script to copy the content from the master item to the clone item and then disconnect the clone from the master.
To redirect the old url to the new one we use the URL Rewrite extension in IIS. First we logged in to Google Analytics to find the most visited pages in the present sites. We copied this list to Excel in column A. In column B we put the corresponding url to the page in the new structure.
Here is an Excel template for you to just populate with your before and after URL: Redirect Rules Excel Template
The template uses the name of the sheet in the formula. Rename the sheet to your domain.
Column A: Most visited pages from search engines
Column B: The address for the page in future web site
Column C: The redirect formula
=IF(A2<>B2;"<rule name="""&MID(CELL("filename";$A$1);FIND("]";CELL("filename";$A$1);1)+1;255)&A2&""""&" patternSyntax=""Wildcard"" stopProcessing=""true"">"&CHAR(10)&CHAR(9)&"<match url="""&IF(LEFT(A2;1)="/";RIGHT(A2;LEN(A2)-1);A2)&"*"" />"&CHAR(10)&CHAR(9)&"<conditions logicalGrouping=""MatchAny"">"&CHAR(10)&CHAR(9)&CHAR(9)&"<add input=""{HTTP_HOST}"" pattern=""*"&MID(CELL("filename";$A$1);FIND("]";CELL("filename";$A$1);1)+1;255)&""" />"&CHAR(10)&CHAR(9)&"</conditions>"&CHAR(10)&CHAR(9)&"<action type=""Redirect"" url=""http://www."&MID(CELL("filename";$A$1);FIND("]";CELL("filename";$A$1);1)+1;255)&B2&""" redirectType=""Permanent"" />"&CHAR(10)&"</rule>";"")
Column D: This formula to create a redirect link for the user to click on to test the redirect rule
=IF(A2<>B2;HYPERLINK("http://www."&MID(CELL("filename";$A$1);FIND("]";CELL("filename";$A$1);1)+1;255)&A2);"")
Column E: Optional notes
I found out when copying and pasting the formula values from Excel to another program there are some extra ” characters hard to get rid of. I think the easiest is to copy the C column and paste it in Notepad++ or similar. Search and replace all
”” to ”
”< to <
>” to >
Now we want Sitecore to use the new redirect rule. I put it in a separate .config file to make it easier to administer, not messing with the web.config file.
Create a Redirect.config file in the D:\Website\App_Config\Include folder and paste the code from Notepad++.
<rule name="wellspect.it/Materiale-informativo-e-video/Informazioni-di-prodotto" patternSyntax="Wildcard" stopProcessing="true"> <match url="Materiale-informativo-e-video/Informazioni-di-prodotto*" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="*wellspect.it" /> </conditions> <action type="Redirect" url="http://www.wellspect.it/Prodotti" redirectType="Permanent" /> </rule>
Include the file from web.config in the
<rewrite> <rules configSource="App_Config\Include\WellspectRewrite.config" /> </rewrite>
Stop and start the IIS to force it to read the new rules. Then test the old url:s by clicking through the Column D addresses.
RRS feed