Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache HTML Directory 1

Status
Not open for further replies.

dracula007

Programmer
Mar 18, 2006
3
CA
Hi guys,

I want to have a directory under htdocs used only to store static files such as HTML or pictures.
Even if this directory contains PHP files and these files are requested, I don't want Apache to respond to the PHP files requests.

Is there any way to do it using Apache configuration?

Cheers

-Dracula
 
Yes, create a directory container for that sub-directory in httpd.conf. Then use the following directive inside it. It will look something like this:

Code:
<Directory "path/to/sub-directory"> 
    Order allow, deny
    Deny from All
</Directory>


 
Thanks RhythmAce for replying,

By Denying from All, Apache will not accept any request.

What I want is to accept only static pages requests such as pictures or HTML And deny all the dynamic pages requests such as PHP or Perl.

Is there any method that enables Apache from distinguishing between static and dynamic pages?


Thanks in advanced
 
Hi again,

I solved the problem,
If you want to reject PHP requests, for example, in a specific directory, you can use:

<Directory "D:/Programs/htdocs/test/">
<Files "*.php">
Deny from all
</Files>
</Directory>

Ofcourse, you can reject everything by denying the files: "*.*" then you can specify only the files you want to allow like *.html, *.htm, *.gif ...

So, In this way you can customize the files you want to accept in a specific directory.

This method can be used when there is a risky directory. E.g. maybe you allow the users to upload files to the server then you must make sure that no one can execute these files in case they were executable. So in the directory that you gave users the permissions to upload, you deny PHP files preventing them from being executed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top