parse HTML as PHP with Htaccess

Asked

Viewed 385 times

1

I have an html site and want HTML pages to be parsed as php; I’m using a . htaccess file for this.

On the localhost server, it works correctly. The command is:

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

However, the online server does not work. When I access the page, it asks to download the file instead of displaying the page.

I’m using PHP 5.5 the Apache and Apache version/2.4.10 I have several php includes inside the html more so I would have to change all pages to . php more would take a lot of work so I want to leave everything with . html more running the includes but only that the code does not work on the online server

I tried all kinds of similar commands in htaccess, like:

  • Addtype application/x-httpd-php . html . htm

  • Addtype application/x-httpd-php5 . html . htm

  • Addhandler application/x-httpd-php . html . htm

  • Addhandler application/x-httpd-php5 . html . htm

  • Addhandler x-Mapp-php . html . htm

  • Addhandler x-Mapp-php5 . html . htm

but unlucky.

I also tried

  • Remove . html . htm but to no avail.

I checked on the server if . htaccess is active and this tested a code and worked normal the problem is in the same code

  • Create a .php it runs normally? because it does not rename all files, like rename -S .html .php *.html, for example.

1 answer

0

Edit or create the file with the name .htaccess inside the directory where the html files are and put the following command:

For Suphp linux servers: AddHandler php-script html

For linux servers that are NOT Suphp: AddType application/x-httpd-php .html

  • Even so it didn’t work out Keep on making the mistake

  • Weird, Voce uses Cpanel?

  • IN THE cPanel can also change this in section MIME Types

  • already seen too but the error continues I switched server I went to hostgator and it worked working normal I think the problem was the other server I used Addtype application/x-httpd-php5 . html and worked even so thanks ai for the help

  • 'Cause it had to be something with the server config ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.