Jump to content

Ways to prevent Apache from serving a folder?


JudgementDay

Recommended Posts

What are some ways to prevent Apache from serving a folder in the root directory?

 

I have raw data in there containing PHP with passwords for my SQL database, and I don't want it being served up.

 

I'm thinking just .htaccess with a password.

 

Is it possible to do within my servers configuration file?

 

I want to hear what other people would do.

Link to comment
Share on other sites

Since php is a server side language, no one can get your database username/password that is contained within php code by browsing to the file, unless you are echoing those values. It would require someone to have direct access to the php source code, but if they already have that level of access to the files on your server, nothing you can do would prevent them from learning the username/password.

 

You can prevent the wasting of server resources, should someone start requesting the file, by putting the file into a folder that does not permit any http requests. You can either put the folder outside your document root folder (closer to the disk root) or put a .htaccess file in the folder that prevents all http requests.

 

 

Link to comment
Share on other sites

  • 4 weeks later...

Off the top of my memory...

Order Deny, Allow
Deny from All

Something along those lines, in a .htaccess file. Or a <directory> section in your httpd.conf

 

It's not safe to rely on PHP not printing out the passwords. If something goes wrong, your source code (and passwords) will be out there for the world to see.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.