How to make PHP code execute in .html files

Very often people ask how to make php inserts work in ordinary .html files, and in general the php code works correctly. So, you just need to edit your .htaccess file. If you do not have such a file, you can create it at the root of your site in the public_html folder

Add the following code to your .htaccess file:
AddHandler application / x-httpd-lsphp .htm .html
After adding this line to the file - you can use php inserts on your .html pages.

IMPORTANT: Make sure to back up your original .htaccess file, as making changes to this file may disrupt access to your website.

  • 33 Users Found This Useful
Was this answer helpful?

Related Articles

How do I set up directory browsing?

When a browser looks at a site directory that does not have an index.html file, the browser can...

How to add your site to search engines like Google, Bing, Yahoo?

Your site is not automatically added to search engines. There are many ways you can add your site...

5 best SEO plugins for WordPress

WordPress is the most popular CMS, it is fast and easy to use for novice users. Filling a website...

How can I protect the source code of my site?

Unfortunately, the source code cannot be protected. Anyone can see the code for your site by...

Can I change the timezone using .htaccess?

If you are unable to change the time zone using PHP functions in your script, then you can change...