Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore: Serve up files within a folder within the content tree

I was wondering the best way to simply be able to put files on the server and have them served up.

www.mycompany.com/Folder/Bunchoffiles.pdf

www.mycompany.com/Folder/ATransformation.xsl

www.mycompany.com/Folder/crazyLogo.png

is there a simple way of just adding files to a folder in the content tree? Can I add these files to the media library and then put them in the content tree somehow?

Sitecore CMS 6.5

like image 389
DFTR Avatar asked Jan 30 '26 10:01

DFTR


1 Answers

If the .ashx extensions bother you, you can disable them in favor of the normal file extension by doing the following:

Create a file in /App_Config/Include called MediaSettings.config or similar with the following:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="Media.RequestExtension">
        <patch:attribute name="value"></patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

If the /~/media prefix bothers you, you can also modify that. Again, modify the file from above like so. This will allow your new prefix path (see: -/media) as well as supporting the original ~/media:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="Media.RequestExtension">
        <patch:attribute name="value"></patch:attribute>
      </setting>
      <setting name="Media.MediaLinkPrefix">
        <patch:attribute name="value">-/media</patch:attribute>
      </setting>
    </settings>
    <customHandlers>
      <handler trigger="-/media/" handler="sitecore_media.ashx"/>
    </customHandlers>
  </sitecore>
</configuration>

John West has already written a great blog post on the subject that covers these and other things. I recommend you check that out. Alternatively, if you simply must have a file at /Folder/MyFile.ext you can create those folders and upload those files to the locations you need on the web server in the web root.

like image 74
Patrick Jones Avatar answered Feb 02 '26 07:02

Patrick Jones