Skip to main content

HTML5 wont process/parse as PHP7/PHP [Resolved]

So i had to reconfigure my linux server because i migrated it to another system and decided to set it up from scratch just for fun and practice. Only issue is that now my LAMP is running with PHP7 instead of PHP5 like i had last time. The issue im running into is that my HTML/HTML5 files are not running or being processed as PHP. I have created the .htaccess file and changed from AddType and AddHandler, changed application/x-httpd-php70 to application/x-httpd-php7, application/x-httpd-php7.0 and different variations of that but it is still not working at all. What i do see is that part of the PHP code is visible as such.

enter image description here

I did notice that if i remove the

from my php code, all the php is hidden again. Also changed up the " " to ' ' and double checked that no syntax has changed from php5 to php7 which it has not. I have tested a .php file with and works perfect as long as its .php. As soon as it is changed to .html that is when it stops working. PHP modules are enabled in apache2.4. I have restarted apache2.4 countless times when changing files in the web root and i have reviewed tutorials on how to install PHP7 with apache2.4 on ubuntu. I actually installed LAMP during the server installation so i dont see why it would be wrong. I am completely out of ideas. Much much help with this, i have been battling this for nearly 4 days now.

Asked April 21, 2017
Posted Under: Network
1 Answers

You need to specify .html as an extension to the AddHandler specification.

AddHandler application/x-httpd-php-source .html

Or you could use a FilesMatch block to set the handler.

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

There appear to be two handlers for php: application/x-httpd-php and application/x-httpd-php-source. Check you configuration to see which is being used when .php files are processed.

An alternative would be to do internal redirects from .html to .php such as:

  RewriteRule  (.*).html $1.php

You can make his conditional on the .html page not existing. The files would need to be renamed accordingly.

Unless you block or externally redirect .php URLs, requests for .php pages will work. This kind of redirection can be difficult.

Answered April 21, 2017
as i commented on my question, i suppose im just going to use .php instead of fighting it. Obviously it got more complicated, somehow in php7. Thanks for the help anyway. Ill have your question chosen as answer since you tried to help – xR34P3Rx 23 mins ago
 CanDoerz  1 week ago
application/x-httpd-php-source is for pretty-printing PHP source files, not for parsing PHP code. Generally used only for .phps files (if at all). – w3dk 3 hours ago
 CanDoerz  1 week ago
just tried it and it still did not work. And according to the phpinfo page, it seems like its running as Apache2.0 module, so would that be application/x-httpd-php? – xR34P3Rx 8 hours ago
 CanDoerz  1 week ago
@xR34P3Rx I verified my configuration and updated my answer. – BillThor 8 hours ago
 CanDoerz  1 week ago
i did, and it still would not work. i just double checked and it still is not working. – xR34P3Rx 9 hours ago
 CanDoerz  1 week ago
Your Answer