extensions on pdf files causing 404 when using extensionless URLs

Gregg Duncan asked on October 7, 2015 23:56

I have my site set up for extensionless urls. But when I upload a pdf it's given the .pdf extension. Then when links are pointed to this url they return a 404 error. Removing the .pdf extension from the url in the browser window will make it show up. Why is the .pdf extension being added to file document types, when the site is setup to be extensionless.

EDIT: I found the solution to this issue but the comments were closed so I'm putting the answer here for others who run into this issue. The answer was found in the documentation here:

https://docs.kentico.com/k11/configuring-kentico/configuring-page-urls/extensionless-and-custom-urls

You must have the following set up in your web.config file. with this setting the pdf's are displayed properly with or without the extension.

<system.webServer> <modules runAllManagedModulesForAllRequests="true">

Recent Answers


Laura Frese answered on October 8, 2015 17:58

in friendly URL extensions (in Settings > URLs & SEO) add something like this ;.aspx;.pdf

The URLS are separated by a ;, so here I have extensionless, aspx, and pdfs allowed. In your case it may just be ;.pdf

More info Here

0 votesVote for this answer Mark as a Correct answer

Gregg Duncan answered on October 8, 2015 19:34

What I don't understand is if you're using extensionless urls, the documentation says to leave the "Friendly Url extensions" field empty. But it doesn't mention the "Files Friendly Url Extensions". And leaving it blank doesn't make the urls for the File document types extensionless the way it does for Page(Menu Item) document types. You have to enter something into the field starting with a semi-colon to make them extensionless. It seems counter intuitive.

0 votesVote for this answer Mark as a Correct answer

Chidozie Bright answered on September 30, 2016 19:45 (last edited on September 30, 2016 19:59)

The solution provided here still doesn't work for me when dealing with extensionless files. It affects all files that are not .aspx pages including images, word docs and PDF files.

In fact, adding the semi-colon only adds the semi-colon to the end of the URL. Leaving it blank adds the .pdf or whichever extension and provides a 404 error. Adding the ';.pdf' adds that to the end of the URL as well. I am also checking the Redirect Pages to Main Extension box as I don't want to have extensions on the site at all.

Is there any better instruction on how to make this work on files? The current solution breaks all not .aspx files on the site so images and other documents no longer work.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.