Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Armitage 508 posts 2077 karma points
    Jul 18, 2016 @ 12:02
    David Armitage
    0

    Umbraco 7.4 Protect Media Items (Not Viewable by visiting the URL)

    Hi,

    Does anyone know of any way to project media items within a certain folder.

    1. I have some files stored in a folder within the Umbraco media section which need protecting for example everything in the passports folder.

    2. I basically want it so if anyone tries to navigate to the media URL the link just dies or redirects them to a page not found or something. /media/1199/passport-australia.png

    3. I don't want to use MediaProtect and I don't need any type of login to the files. A simple try the link and the file isn't delivered to the user (as if it doesn't exist).

    4. I can see this might be difficult since the URL doesn't contain any information as per the folder. My plan be is to add a re-write rule in my web.config that looks for anything with the word passport and I will make sure all the files I upload that need protecting have this keyword.

    Maybe someone has a better solution.

    Kind Regards

    David

  • David Armitage 508 posts 2077 karma points
    Jul 18, 2016 @ 12:14
    David Armitage
    100

    Hi,

    So my plan B works a treat. I am still interested to how anyone else is handling this?

    Here is what I did.

    1. All my files will share a similar name (contain the work passport)

    2. So I simply add a re-write rule to the main website web.config to look for this keyword in the URL and if it finds it them re-direct to my default page not found.

    Place the code within the system.webServer tags in your web.config

    <system.webServer>
        <!-- rewrite settings to be put in here -- >
    </system.webServer>
    

    This is the example of my re-write information I added within the system.webServer

    <rewrite>
      <rules>
        <rule name="Protect Passports">
          <match url="passport" ignoreCase="true" />
          <action type="Rewrite" url="page-not-found" />
        </rule>
      </rules>
    </rewrite>
    

    Now if anyone tries to visit a url containing the word passport then they are re-directed. Eg. http://mydomainname/media/1199/passport-australia.png

    Hope this solution helps someone else. Anyone with the better solution let me know.

    Kind Regards

    David

Please Sign in or register to post replies

Write your reply to:

Draft