Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AddType in htaccess causes page to download

I have read about 10 questions like this, but there seems to be no answer to this simple question.

What could cause .htm files to be downloading instead of executed as php?

I am using the following code:

AddType application/x-httpd-php htm

I have tried many combinations but no success.

What else can I try?

All I need is .htm and .html files to execute php.

like image 821
user1721135 Avatar asked Jun 10 '13 12:06

user1721135


4 Answers

In Apache and nginx ONLY work .htaccess file:

<FilesMatch "\.html$">
    SetHandler php-script
</FilesMatch>

I've also removed AddHandler and AddType from Apache conf (I used plesk).

like image 116
Serghej Avatar answered Oct 16 '22 12:10

Serghej


Use AddHandler also, change htm to .htm and add .html

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

http://www.suffix.be/blog/addhandler-addtype-directives

like image 37
nick Avatar answered Oct 16 '22 11:10

nick


I had the same issue but then i figured the version of php i'm using is php5. I changed the handler to the following and it worked!

AddHandler x-httpd-php5-3 .php
AddHandler application/x-httpd-php5 .php
like image 35
Noyeem Abdullah Avatar answered Oct 16 '22 11:10

Noyeem Abdullah


I had the same problem and couldn't find the answer here. Did find it on this cpanel forum though: https://forums.cpanel.net/threads/php-script-is-not-working-in-html-file.595195/

Their advice was to use this:

AddHandler application/x-httpd-ea-php56 .htm .html .shtml
AddType application/x-httpd-php5 .php

I was using PHP together with JSON though. After this PHP did work, but JSON didn't. Solved it by removing the AddType and sticking with the AddHandler

AddHandler application/x-httpd-ea-php56 .htm .html .shtml
like image 39
Stephan Avatar answered Oct 16 '22 12:10

Stephan