.htaccess... AddHandler cgi-script php... Options -ExecCGI

  • Posted February 8, 2015

I have a .htaccess file which has the following directive …

Options -ExecCGI AddHandler cgi-script .php .php3 .php4 .php5 .pl .py .jsp .asp .htm .shtml .sh .cgi

It has been placed in the directory, that I do not want files with .php extensions to be accessed. Within /etc/apache2/apache2.conf , I’ve adjusted AllowOverride to All as in the following.

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

The .htaccess works by not allowing permission to access files, of every extension in the list, except .php type files. Of course, .php files are the ones, I’m really wanting not to allow permission too. This file is not for actual production use. Just for tinkering about. It use to work several years ago, but upon returning to use it now, it will not work. The Web hasn’t been useful for an answer. Thanks ahead for any direction.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Since php is handled by it’s own handler you will need to disable this. I recommend adding the following to your .htaccess file to disable php for the directory:

RemoveHandler .php .phtml .php3
RemoveType .php .phtml .php3
php_flag engine off