Forum Moderators: coopster
I just had a quick question which the answer to which would end a lot of grief and suffering for me... :)
Every page on my site (uses .html extension) uses SSIs that have an .htm extension.
Now I am adding php functionality and programming to all those same pages. I can get the .html pages to parse the php using this directive:
AddHandler x-httpd-php .html
Is there a way I can get both the php and the .htm SSIs to render properly?
Thanks!
However, you should be able to use PHP to do just about anything you could do with an SSI instruction anyway. So you should be able to replace the SSI pages with pages coded with PHP.
I would also need to change every page of my site to use php includes and re-upload every page of my site which probably wouldn't be worth it.
I'm not quite sure what you're saying either... what's getting parsed twice? SSI is a parsing method? I'm using the SSIs to handle site navigation, footers, etc. so that I can easily make a change to single file and everything will update. Sorry, I guess I don't know all that much about SSIs when I say that I don't understand the phrase "once with php and then with server side include". It's just html...
If I'm confusing you, just see my original post again. :)
Based on what you've said here, my advice would be to remove the PHP "AddHandler" instruction in your first message from your .htaccess file and replace it with:
AddHandler server-parsed .html .htm
Then put all of your PHP code in external files with a .php extension and use:
<!--#include virtual="external.php"-->
to incorporate the PHP support in your .html pages as needed.
It's just html...
But by telling the O.S. to parse .htm pages for SSI directives, its not html any more. The way SSI works is it reads in the page looking for directives and alters the output dynamically. The "read in" process is called parsing, in the same way PHP parses a script for commands. The script doesn't "execute," PHP executes based on the commands you give it in the script.
The last example is what I'd do. Make a choice and choose one or the other - you can have both, but not both on the same page. So if you have a long list of .htm pages that are static except for the header includes, stick with SSI, or alter the SSI to include output of a php script. If you have pages that **must** use php outside the SSI directives, make them .php - but if it was previously indexed as .htm, a simple rewrite will minimize any SERP damage:
RewriteRule ^oldpage.htm$ oldpage.php [R=301,L]
In the .html pages I have to manually set a php variable to a numeric ID when I include the .php file. What's the best way to do this?
This is how we were planning on doing it:
<?php $PRODUCTID = "1"; include('Aproductinfo.php'); ?>
New way:
<!--#include virtual="/Aproductinfo.php"-->
Doesn't seem to be possible to feed the php include the variable...?