Turn Off PHP Parsing In A Directory

Sometimes it is necessary to turn off PHP parsing for a directory. You might want to give away some source code and therefore don't want to parse that code when the user tries to download it. You could just rename the file to have the extension .phps, which is a PHP source file, but this is an alternate method.

To turn off PHP parsing in a directory just create a .htaccess file with the following content.

php_flag engine off

You can expand on this by adding the following:

AddType text/plain .php

This will force all files to be served as plain text files.

If you are going to use this then be sure that you do not put this in any directory that contains your applications. This will cause your files to be downloadable, including any files with usernames and passwords in.

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
7 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.