Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server not parsing .html as PHP

Tags:

I have the included code in my .htaccess file but the php code I am attempting to include is not working.

Options +Includes
AddType text/html  .htm .html
AddHandler server-parsed .htm .html
AddType application/octet-stream .vcf
AddOutputFilterByType DEFLATE text/html text/htm text/plain text/css text/php    text/javascript application/x-javascript
like image 916
Ben G Avatar asked Jun 09 '11 15:06

Ben G


People also ask

How parse HTML in PHP?

To add the dynamic data (HTML content) at a certain point in PHP code, we need parsing. For example: For adding the data (info) in the form of HTML, we need to make that dynamic template in string and then convert it to HTML. How should we do parsing? We should use loadHTML() function for parsing.

Does PHP interact with HTML?

PHP and HTML interact a lot: PHP can generate HTML, and HTML can pass information to PHP. Before reading these faqs, it's important you learn how to retrieve variables from external sources. The manual page on this topic includes many examples as well.

Does Apache HTTP server support PHP?

PHP support can be added to a number of web servers (IIS, Xitami, and so on), but most commonly Apache HTTP Server is used. Click here for information on how to install and configure Apache 2.2. The PHP engine. The supported version is PHP5.


2 Answers

Try:

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

UPDATE 1

It may be PHP version specific. If you're using PHP5 try:

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

UPDATE 2

Try:

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

Or here's yet another alternative way to do this:

<FilesMatch "\.html$">
    ForceType application/x-httpd-php
</FilesMatch>
like image 67
John Conde Avatar answered Sep 30 '22 02:09

John Conde


On Apache 2.2.22 (Ubuntu) with Php 5 add these lines to /etc/apache2/mods-enabled/php5.conf

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

and restart apache

sudo service apache2 restart
like image 35
Gjaa Avatar answered Sep 30 '22 01:09

Gjaa