Coding: PHP



Parsing PHP in HTML pages

With a little tweek of the .htaccess file it is possible to use php codes from within your regular html pages. The pages will be parsed just as if they were native .php pages.

Edit the .htaccess file

Go to your website's root and look for the file named .htaccess. If it's not there, create a blank text file using NotePad or your favourite plain text editor and save it as .htaccess

Edit the .htaccess file by adding the following lines:

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

Save and upload the .htaccess file to your webserver.

The .htaccess file only effects documents within it's own folder and subfolders below. For example, putting this code in the route will effect all html files for the whole site, putting the code in a subfolder will only effect files and folders within that subfolder.

Alternatively...

Some hosts are set up differently (Heart Internet for example). If you find the above fails to work with your website, try this code in your .htaccess file instead. Replace .html with .htm if that is the extension you have used for your pages.

AddHandler cgi-script .html
SetEnv PHP_EXTENSION .html

 
 
 
 

1066 Internet - bespoke Hastings web site designs Web Design Hosting SEO Directories