cparfon
cparfon

Reputation: 177

configure apache run run php in html pages

How can I make apache parse php code inside my html pages? I don't wanna use .htaccess. I've added:

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

in my vhost file for one of the websites but it won't work.

Upvotes: 2

Views: 7650

Answers (2)

Arnau Castellví
Arnau Castellví

Reputation: 240

I have the same problem in the latest versions (Debian 10 , Apache 2.4.25, PHP 7.0.33)
My solution is edit the php.config file, to find it I put:

find -iname php*.conf

...and in my debian instalation I found it in:

 /etc/apache2/mods-available/php7.0.conf

Then, I introduce those lines at begining:

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

And it work for me.

Upvotes: 3

Jerry
Jerry

Reputation: 76

Did you build your Apache binary with PHP? Or if you built a SO, reference it in the Apache config (e.g.: LoadModule php5_module modules/libphp5.so)?

When using .html for PHP, ensure 'AddType text/html .html' is removed, so it doesn't conflict with the x-httpd-php reference.

FYI -- you can create one entry 'AddType application/x-httpd-php .html .php'

Upvotes: 2

Related Questions