Forum Moderators: phranque

Message Too Old, No Replies

Parsing HTML as PHP

         

flycast

2:16 am on Dec 13, 2005 (gmt 0)

10+ Year Member



I have an existing site that has mostly html files and a few php files. The client wants to display a flash ad in the page structure on the first page a user gets in that session. The flash ad would not be displayed after that until the user started a new session (closed a browser, ect.). I thought I would do that with PHP and sessions.

The challenge is that most of the files are HTML and I don't want to rename them as PHP files and lose Google pointers and bookmarks.

How would you go about solving this problem?

1) Parse the HTML files through the PHP interpeter? If so, how?
2) Rename the HTML files as PHP?
3) Permanant redirects?
4) Any other options?

encyclo

2:20 am on Dec 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Option 1 is by far the best: if your server is running Apache then you can add this line to your root-level .htaccess file:

AddHandler application/x-httpd-php .html

Redirects, even 301 permanent ones, are potentially damaging to your rankings.

flycast

2:36 am on Dec 13, 2005 (gmt 0)

10+ Year Member



That does not work on my server for some reason. I edited my .htaccess file with the line and posted a file test.html with the following content:
<?
phpinfo();
?>

All I get is a blank page in the web browser. When I look at the source for th page it did get the page properly, it just hasn't passed through the PHP interpeter.

WebWalla

8:40 am on Dec 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a couple of sites that work with the following line in .htaccess ...

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

Maybe somebody could enlighten us as to the difference between AddType and AddHandler?

flycast

1:07 pm on Dec 13, 2005 (gmt 0)

10+ Year Member



WebWalla
AddType did the trick.
Thanks a bunch!