In scenarios when we are migrating the website from other platforms to Sitecore CMS. We might have many URL to be get redirect to new URL. In such cases most of the older URLs may also contain extensions like ~/oldurl.php, ~/oldurlpdfdoc.pdf or ~/oldurl.aspx.
Sitecore SXA's provide redirect feature but with some limitations. Here we get the feasibility to set Redirect but that only work for below scenarios.
- Redirecting existing item in Sitecore tree to new.
- We can't redirect any link containing extensions like php or pdf.
But again old url can not always be in Sitecore item URL formats and we may need some other solutions apart from this. Hence such requirements can be fulfilled by using Constellation Redirect Manager (an external package for marketing redirects). Please refer the official documentation here.
Constellation Redirect Manager:
- Redirecting any url (without extensions) to new which can be relative or absolute URLs (including other domains).
- Including file extension in old URL does not come by default (but can be implemented).
I have read its documentation and found it has mentioned that file extensions can be included in old URLs only if developers can enable to use it in the Constellation Redirect Manager.
Image: Constellation Documentation for file extensions in URLs.
In this article, we will see how to enable authors to use URLs with file extension for redirects.
Lets see how we can enable redirect URL containing extensions like PDF and PHP using Constellation Redirect Manager:
To make it possible the request should be able to be reach to constellation redirect code. But here the problem is Sitecore NOT allowing any other request with contains file extensions in URL. It only allow the below file extensions in the request.
Image: Config for allow extensions in Sitecore
Because of that any request containing file extension can't reach to constellation program. So, here we add exception for pdf or php so that the request can be reach to constellations redirect code.
Here we will make some changes in Sitecore configurations. We will add the file extensions we want to the Allowed extensions list of the Sitecore configurations.
I have created a separate patch file and will keep Sitecore's existing file extensions (like aspx, ashx, asmx) & file extensions we need (like pdf, php) as shown below. Add this patch file to the respective project App_Config folder.
Patch Config File:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" > <sitecore> <pipelines> <preprocessRequest> <processor> <param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, pdf, php</param> </processor> </preprocessRequest> </pipelines> </sitecore> </configuration>
Image: Patch Config file for allow extensions in Sitecore
Here, your Sitecore instance will start allowing the request with pdf and php urls. Now you can add redirect on your Redirect Manager and verify the changes.
0 Comments