You don't have to rename file_as.html to file_as.php. You can eliminate the hassle of losing search engine link. There's another trick to redirect incoming ****.html to be redirected to ****.php, but for this demonstration purpose I'm just going to talk about including regular PHP expressions to regular HTML page.
I was faced with editing 100+ HTML files to have URL changed within each page. Although I could have easily done it with HTML editors, copy, paste, save and then upload, I wanted to know if I could do it in a way that would be better for the future. I mean what if I have to change this URL to another format, or include additional information to 100+ HTML files? Do I go through of editing them all over again? If they were a PHP file I would simply include 1 file which can be edited. Then the 100+ pages will reflect the change immediately by uploading a single changed file.
Using htaccess native command,
RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html
Save this as .htaccess and upload it to the directory where your files will be affected.
Once uploaded, simple have your HTML file to include a code like
<body>
...
...
<?php
include ('filename.php');
//or
for ($i=0; $i<sizeof($array); $i++) {
echo $array[$i];
}
?>
...
...
</body>
</html>
As you can see, although your file still possess file_as.html, you can make it to run PHP code. And all PHP codes will run normally--no exceptions or exclusions.















