Last updated on December 15th, 2022 at 09:48 am
Sometimes the AddHandler application/x-httpd-php .php .htm .html .my or whatever you put inside .htaccess file or in HTTPD.conf it doesn’t work
Because if you are in a shared hosting it will be always better to find out the version of PHP currently running on your server using the below script
<?php echo 'Current PHP version: ' . phpversion(); ?>
So if your host is using PHP v 5+ then the handler that is specified for example
AddHandler application/x-httpd-php .php .htm .html .my
will not be working as expected, once you hit the page you will be either asked to save the webpage or probably if you check the source you can see your php codes are not compiled.
How to fix this?
Its pretty simple you just need to add the below handler in your .htaccess file
AddHandler application/x-httpd-php5 .htm .php .my
Now if the above didn’t work try these other tricks
For example If you want to run a file with .jpg extension as PHP then try this
<FilesMatch \.jpg$> SetHandler application/x-httpd-php </FilesMatch>
If you want .php1, .php2, .php3 and .phtml files to be executed as PHP, but nothing else, we’d use this:
<FilesMatch "\.ph(p[1-3]?|tml)$"> SetHandler application/x-httpd-php </FilesMatch>
Also don’t forget to check this tutorial on other scenarios in which PHP Code not getting executed , code visible
4 thoughts on “Apache AddHandler application/x-httpd-php not working?”
Its work my site
Don’t work for me 🙁
Please let me know what exactly is your issue?
Thanks, a lot! I’ve been searching all day…