Give a second life to non-existing URLs
When you change the page URL title or move pages around, their URLs get broken. If someone mentions an URL to a page on your website, and you somehow change it afterwards, you will probably lose quite a few visitors because of "Error 404".
One way of solving this problem is to use friendly URLs in C1.
Another way is to keep track of changes to the page URLs on your website and maintain a mapping of old URLs to their new equivalents.
Composite.Tools.LegacyUrlHandler helps keep track of changes to URLs and map no longer existing URLs (legacy URLs) to new ones.
For information about fixing broken links on your website with Composite.Tools.LegacyUrlHandler, please read "Fixing Broken Links".
How It Works
The tool takes a "snapshot" of all the current paths to pages on your website before you make any changes. It saves them at /App_Data/LegacyUrlMappings.xml and maps a relative URL to a page ('/MySite/MyPage') as an "old path" to its equivalent rendered internally in C1 by Page ID ('~/page(41328915-3f56-423f-ab8d-157ddc9c8af8)') as a "new path".
<Mappings> <Mapping OldPath="/Omnicorp/Test" NewPath="/page(3855c83f-e260-41ac-9779-a546e0d60a56)" /> <Mapping OldPath="/Omnicorp/Test/Forms" NewPath="/page(41328915-3f56-423f-ab8d-157ddc9c8af8)" /> </Mappings>
After you are done moving pages or changing their URLs, you run the tool to remove unchanged paths so the file finally contains only changed URLs. Since the page ID is not changed when you change the Page URL title or move a page, it redirects a visitor opening the page by its old URL to the correct page (resolved by C1 to its new URL.)
How to Use with Legacy URL Handler
After you install the package, you get two ASPX pages in the root of our website:
- /StoreCurrentPaths.aspx
- /RemoveRedunantPaths.aspx
Before you change URLs on your website:
- In your browser, open the
/StoreCurrentPaths.aspxpage (e.g.http://www.contoso.com/StoreCurrentPaths.aspx). - Click Start. The tool will store all the current paths.
- Make changes on your website that will change the URLs to pages.
- In your browser, open the
/RemoveRedunantPaths.aspxpage (e.g.http://www.contoso.com/RemoveRedunantPaths.aspx). - Click Start. The tool will remove all unchanged URLs fro the mapping file.
Note: You can use the link on both pages to switch between them.
If you repeat the steps, new changes will be added to the mapping keeping the previous ones.
Important: Make sure you run "StoreCurrentPaths" before making changes to URLs and "RemoveRedunantPaths" without missing any of these steps.
Adding Mappings Manually
You can add mappings manually. This can be the case when an old page ceased to exist. In this case, it might make sense to map the old URL to some related page instead.
To add a mapping manually:
- In the System perspective, edit
/App_Data/LegacyUrlMappings.xml. - Add a
<Mapping/>element specifying the old path (OldPathattribute) as the relative URL and the new path (NewPathattribute) as '~/page({GUID})' (where{GUID}is the page ID).
See the sample above.
Requirements
Composite C1 version 3.1 or later