简体   繁体   中英

enable again apache2 to parse html file as php7 using .htaccess

I have an Ubuntu 16.04 64bit desktop and php7 enabled by default.
Some client of mine like to embedded php script into html page.

some time ago I write a .htaccess file like this:

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

Now this syntax is no more working.
I have try a lot of same syntax but nothing work.

I had to change /etc/apache2/mods-enabled/php7.0.conf adding

<FilesMatch ".+\.html?$">
    SetHandler application/x-httpd-php
</FilesMatch>

but this is not a good solution: all html page are enabled to be parsed as php file!

Someone have right new configuration?

PS in site's conf file I have AllowOverride All enable on site directory

You can try the following solution in your .htaccess :

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

Worked for me with PHP7.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM