September 18, 2020, 12:27:35 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
   Home   Help Search Login Register  
Pages: [1]
Author Topic: Make html pages work like php without changing extension  (Read 13383 times)
Hero Member
Posts: 790

« on: January 03, 2007, 01:02:57 PM »

Some day you may need to add dynamic to your static html pages. But how to accomplish that?

You could change extension on all .html pages to .php, but in this case all inbound links linking to those pages will be broken. PageRank will be lost.

Another solution would be to leave all filenames as is, and change server settings instead (to parse html files as php files).

Use either of below approaches.

1) Changing httpd.conf.
Search for AddType application/x-httpd-php .php line. If line exist just add " .html" at the end (without quotes, note space)
If the line does not exist then add following line to the file.
AddType application/x-httpd-php .php .html

2) Changing .htaccess.
AddType application/x-httpd-php .php .html

After that all your html files would be processed by php preprocessor. This means you can add php code to html pages. Make sure to enclose php code with <?php   ?>  tags.

Note: doing so will take a little more server resources since php preprocessor would also need to parse html pages before showing them to your website visitors.

Pages: [1]
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC