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


4 Steps to Win Advocates and Implement a Technical Change

A Lodestar for Ethereum Consensus #3

Cloud adoption in the iGaming industry

Guide to building an Access Control & Permissions modules for SaaS Applications

Building A Simple Voice Assistant for Your Mac in Python

Roadmap of the Crodo project, the big goals of this platform

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

Cookies With PHP

Laravel Queue Worker for Windows

PHP for Beginners: Loops

A Mini Php Mvc Structure: Zerdesht