I've been trying to get .html files to process like .PHP files, using the .htaccess file. I've used the following, both of which don't work and trying to access the test page gives me an option to download a file that doesn't exist. How can I fix this?
I tried both of these;
AddType application/x-httpd-php .html .htm
AddType application/x-httpd-php5 .html .htm
The idea is to allow includes in my web pages, but still using .html files.
Below is some more code from my .htaccess file, I don't think it's messing with the addType, but I'll post it up.
## Hide .html extension
# To externally redirect /dir/foo.html to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [L]
1&1 IONOS have decided to only allow me to do it with the following code;
AddHandler x-mapp-php5 .html .htm
You need to add
AddHandler application/x-httpd-php .html .htm
Try this:
AddHandler application/x-httpd-php .html .htm
or
AddHandler x-httpd-php .html .htm
or
<FilesMatch "\.(htm|html|php)$">
SetHandler application/x-httpd-php
</FilesMatch>
or
<FilesMatch "\.(htm|html|php)$">
SetHandler application/x-httpd-php5
</FilesMatch>
Edit: For 1&1 server:
AddType x-mapp-php5 .html .htm
One of these should work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With