Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to disable the php engine in all directories below the current one.

I have tried using <Directory> and <DirectoryMatch> but cannot find the correct regex syntax for matching just sub directories.

Example directory structure:

files/folder1/ files/folder2/ files/folder3/folder3a

I want to match folder1/, folder2/, folder3/ and folder3a/ but not files/

Any ideas?

share|improve this question

what you're doing here is inverting hierarchy. Everything is designed to work the other way around. My advice would be to change your folder structure so that you don't need to do things backwards.

Perhaps have one folder for your scripts, and enable PHP in that only, and another folder containing everything else.

share|improve this answer

Just in case someone needs it, firstly tell apache to treat your php files as text files by dropping the following directive in the the directory you want:

AddType text/plain .php

Then in all subdirectories under it, turn them back to scripts:

AddType application/x-httpd-php .php

This should work if the lines are in .htaccess files or <Directory> directives

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.