Allowing PDF file redirects on the Sitecore website
As per the Standard Sitecore setup, the PDF redirects are not allowed or handled via Sitecore. This blog is intended to demo the use case to allow redirects of PDF files.
In order to give the freedom to Content Authors, so that they can setup these PDF redirects, the PDF extension is required to be allowed in the below processor FilterUrlFilesAndExtensions.
Below is the configuration required for a SXA website:
<sitecore>
<pipelines>
<preprocessRequest>
<processor type="Sitecore.XA.Foundation.SitecoreExtensions.Pipelines.PreprocessRequest.FilterUrlFilesAndExtensions, Sitecore.XA.Foundation.SitecoreExtensions">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, pdf</param>
</processor>
</preprocessRequest>
</pipelines>
</sitecore>
<pipelines>
<preprocessRequest>
<processor type="Sitecore.XA.Foundation.SitecoreExtensions.Pipelines.PreprocessRequest.FilterUrlFilesAndExtensions, Sitecore.XA.Foundation.SitecoreExtensions">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, pdf</param>
</processor>
</preprocessRequest>
</pipelines>
</sitecore>
After making the above change, the URL https://sc102.dev.local/dummypage/dummy.pdf gets redirected successfully to https://sc102.dev.local/home
Below is the configuration required for a normal Sitecore website without SXA module:
<sitecore>
<pipelines>
<preprocessRequest>
<processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, pdf</param>
</processor>
</preprocessRequest>
</pipelines>
No comments:
Post a Comment