.htaccess does not seem to be working



There is no error message from what I have seen, but nothing seems to be working…

I’m trying to get php code into .html files. It does not work by default, and that’s fine. I create a .htaccess file in the htdocs file in my directory, at put in the following code:

AddType application/x-httpd-php .htm .html

I save the file and try to make php code in an html file, but it’s not doing anything. I think it’s that the .htaccess isn’t working.
I have not found any error messages. (In the file or the website page)

Put this in your .htaccess (at the very top) to see if there are really any errors with itself/your php:

php_value display_errors On

And if that doesn’t work, maybe change the file extension to .php. Then you can use a .htaccess RewriteRule to change the visible extension in the browser url:


You cannot use PHP in a .html file, your extension needs to be .php. Correct me if I misunderstood.

By far the easiest way to make sure your PHP code gets executed is to put the code in a file with the .php extension. That’s guaranteed to work on every server that supports PHP.

If you want .html in your URLs, you can also just setup your code with the .php file extension and then use .htaccess RewriteRules to dynamically rewrite all .html URLs to .php. This example does that: .htaccess - redirect all .html extensions to .php - Stack Overflow

For going to route you took, I’m not sure if that works here. It might be that the line is wrong, I see examples with AddHandler instead of AddType and different content types too. And it might be that these .htaccess directives are not allowed on our hosting.


I thought that was the rule as well.

This is generally the case if you do not set up any server-side processing rules. But, as we solved in this topic, you can if you write some server-side rules (.htaccess rules) to do so.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.