Throw scripts as text instead of executing it

To throw PHP or other scripts as text instead of executing it, add the below code to .htacess file.

AddType text/plain .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo .sh .html .shtml .jsp

This method can be used to execute .html files as .php (or for executing any other type of file as some other type).

This requires mod_mime module of Apache to be installed and enabled.

There might be problem if su_php is enabled. In case the above doesn’t work for PHP scripts when suPHP is enabled then try adding the following to Apache Directives (main is the highlighted code).

<Directory /var/www/domain.com/files/images/>
        suPHP_Engine off
 </Directory>

It is not a good idea to disable suPHP for the whole site, instead disable only for the required directory.

One thought on “Throw scripts as text instead of executing it

Leave a Reply