logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: enable php for SOME directories
Author
steeman



Joined: 29 Feb 2016
Posts: 2
Location: Belgium, Brugge

PostPosted: Mon 29 Feb '16 18:02    Post subject: enable php for SOME directories Reply with quote

I want to disable php except for some users
So, deny it on the top-level
Code:

<Directory /var/www/>
  Order allow,deny
  allow from all
  <FilesMatch "(?i)\.(php|php3?|phtml)$">
    Order Deny,Allow
    Deny from All
  </FilesMatch>
</Directory>

and allow it on a specific directory
Code:

<Directory /var/www/XYZ>
  <FilesMatch "(?i)\.(php|php3?|phtml)$">
     Order Allow,Deny
     Allow from All
  </FilesMatch>
</Directory>


This works!

But: for some directories I want to enable Option Indexes with the module 'dir' and DirectoryIndex

Code:

<Directory /var/www/ABC>
  Option Indexes
</Directory>

This doesn't work because I use the dir module who tries index.php --> access denied on ABC

2 bad solutions:
1) don't add index.php in DirectoryIndex
2) enable php on the directory which needs Indexes
Code:

<Directory /var/www/ABC>
  Option Indexes
  <FilesMatch "(?i)\.(php|php3?|phtml)$">
     Order Allow,Deny
     Allow from All
  </FilesMatch>
</Directory>

Now the question: who has a better solution to
- disable php globally
- enable php on some directories
- enable Indexes on some directories without the need to enable php
- use the module dir (DirectoryIndex index.html Index.php)

Quite a puzzle!

I use
- apache 2.2
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Tue 08 Mar '16 17:52    Post subject: Reply with quote

It can be a lot easier with the use of

php_admin_value engine Off
or
php_admin_value engine On




Note that this will give a 500 error if PHP is not installed as mod_php. Wrap it in <IfModule mod_php5.c> ... </IfModule>
Back to top
steeman



Joined: 29 Feb 2016
Posts: 2
Location: Belgium, Brugge

PostPosted: Tue 15 Mar '16 18:31    Post subject: Reply with quote

I think that is unsafe. When you surf to a php-file in a protected directory, you can read the source (passwords!).

In an ideal world there should not be php-code in a protected directory, but we can't control all our users.
Back to top


Reply to topic   Topic: enable php for SOME directories View previous topic :: View next topic
Post new topic   Forum Index -> Apache