Help: password protecting downloads / directories

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
benb

Help: password protecting downloads / directories

Post by benb »

I've been trying to get this to work, but have yet to be successful.

On our current (static) site we have pages and files in a user/password protected directory.

Like this:

/index.php
/contactus.php
/portal/*  parameter, but can't figure out how to implement it.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Help: password protecting downloads / directories

Post by calguy1000 »

use the Uploads module + CustomContent + FrontEndUsers to setup your secure downloading
to prevent direct access to the files create a .htaccess rule that only allows access to the files directories by localhost

i.e:

Deny All
Allow from 127.0.0.1
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
benb

Re: Help: password protecting downloads / directories

Post by benb »

Do I create that htaccess file inside the folder that has the files I want to protect? Also, is the text you provided all that needs to be in the file?

I've only used the cpanel 'web protect' menu for protecting directories, so I'm not familiar with the syntax of htaccess.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Help: password protecting downloads / directories

Post by calguy1000 »

Yes you put the .htaccess file into the directory you want to protect, and no you'll have to google and find all that you need, but it's pretty close.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
benb

Re: Help: password protecting downloads / directories

Post by benb »

Ok, I feel I'm getting close, but still no cigar.

I created a htaccess file with the following and placed it in the directory I want protected:


    order deny,allow
    deny from all
    allow from 127.0.0.1


When I do that I cannot access the file at all. I've tried changing it to locahost, and just the IP of my server with no luck. Is there a chance my host will not allow this?

The file is uploaded into a folder I created with the uploads module that has the proper FEU permissions for the user I login as.

I then use the following in a page to try to create the link to the image in the directory:

Code: Select all

{cms_module module=CustomContent} <!--customContent: startif group=testgroup,admins -->
<p>This content is only available to logged in testers and and admins  <a href="uploads/pfiles/flickr.jpg">Image</a>  <br /> 
<img src="uploads/pfiles/flickr.jpg" />  </p>
<p> <!--customContent: else --> </p><h1>You must login to view this page's contents.</h1> 
<!--customContent: endif --> <!--customContent: startif group=users --> 
<h1>This content is only available to logged in users </h1> <!--customContent: endif -->
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Help: password protecting downloads / directories

Post by calguy1000 »

that is still technically accessing the file from the remote site
try {Uploads mode='summary' category='whatevercategoryyoucreated'} and then it should work.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
benb

Re: Help: password protecting downloads / directories

Post by benb »

Hmm, I can't get that to work even with the htaccess file removed.

I've tried both:
{Uploads mode='summary' category='TestImages'}

and

{cms_module module="Uploads" category="TestImages" mode="summary"}
benb

Re: Help: password protecting downloads / directories

Post by benb »

I think I may have to admit defeat on this one. I can't make it work.
Locked

Return to “CMSMS Core”