Allow PHP in HTML files to execute

By default on Apache web servers, PHP code will not execute in a file that does not have a .php (or similar) extension. So even though you can embed PHP into a HTML file, it won’t execute when the file extension is .html, .htm etc.

To change this, you can add a .htaccess file to allow PHP execution.

Here are some examples depending on your system:

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

For certain hosting providers you may need to do this (adjust for PHP version too).

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

Put this in a file called .htaccess in the same folder as your HTML files.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

[Codility Series — Python solution] Lesson 2.1 CyclicRotation

50 + Basic Oracle Interview questions

Differences between Hard Link and Symbolic Link — Linux

Datadog Log Management from Zero to One

How to create a wwdc scholarship submission and win

How to Get Around Creating Custom Routes in Ruby on Rails

Image result for custom routes ruby on rails

Imposter Syndrome in Software Engineering

Apps for studying Spanish vocabulary

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Praj Basnet

Praj Basnet

More from Medium

How to connect PHP application to MSSQL, setup on 2 different servers.

Laravel 9 Authentication using Breeze Tutorial

Setup Redis on Laravel project 💡

Laravel 9 released!