AddHandler not working for .php files - Apache 2.4 AddHandler not working for .php files - Apache 2.4 php php

AddHandler not working for .php files - Apache 2.4


You might want to try SetHandler instead

<FilesMatch \.php$>    SetHandler helloworld</FilesMatch>


SetHandler will remove any previously set handler. To get the option for your handler to run first then run the default PHP handler when your handler returns DECLINE you need to set yours first, then add PHP

<FilesMatch \.html$>    SetHandler helloworld .html</FilesMatch><FilesMatch \.php$>    SetHandler helloworld .php    AddHandler php5-script .php</FilesMatch>

Note that this has the effect of clearing any handlers previously setup for .html files

You can only have one handler handle any file type per request. If you always want the PHP interpreter to run first and then your handler to run second you could consider AddOutputFilter directive.

Most phases are terminated by the first module that handles them; however, for logging, `fixups', and non-access authentication checking, all handlers always run (barring an error).

Apache API reference

AddOutputFilter docs


You need to restart your Apache server after adding handler.

Check also if extension will actually be interpreted by the server the way you want it to work. You can check that sort of info from system admin of your hosting provider. Many sysadmins disable some features to improve security.