Handle any requests and any extensions in Sitecore

In this article, we will look how to Handle any requests and any extensions in Sitecore without writing any code. With some configuration changes, we could easily allow Sitecore to process all the file extensions.

By Default Sitecore allows only “.aspx and .asmx” extensions during the request. If any other extension is tried then it will not hit the code rather the IIS will throw a 404 error saying file not found. So let’s say if you need to implement 301 redirections from legacy .java or .php extensions. How exactly could you make this work?

Handle any request and any extensions in Sitecore

If we closely look into the Sitecore web.config file, the default extensions allowed are .aspx, .ashx and .asmx files. All the other extensions are blocked. Hence the IIS will not handle any other extensions and the default 404 error page will be shown when we hit any other extensions.

In order to handle any file extensions and any request in Sitecore just remove the “*” from <param desc=”Blocked extensions (comma separated)”>*</param> and place the * in the <param desc=”Allowed extensions (comma separated)”>*</param>.

The updated config file section will look similar to the snippet mentioned below.

Handle Specific Extensions in Sitecore

Many times you need to handle only specific extensions types in Sitecore. For Eg: Let’s say you  need to implement 301 redirections on the legacy PHP pages to new Sitecore pages. The extension of the legacy site will end with .php always. In order to allow specific extensions just add the extension in the config section as shown below.

Once you add the extension the Sitecore is capable of handling the requests. You could override the HttpRequestProcessor pipeline and implement the 301 redirections in Sitecore

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *