Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: enable php for SOME directories |
|
Author |
|
steeman
Joined: 29 Feb 2016 Posts: 2 Location: Belgium, Brugge
|
Posted: Mon 29 Feb '16 18:02 Post subject: enable php for SOME directories |
|
|
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: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 08 Mar '16 17:52 Post subject: |
|
|
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
|
Posted: Tue 15 Mar '16 18:31 Post subject: |
|
|
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 |
|
|
|
|
|
|