PDA

View Full Version : PHP and SSI Parsing Question


royrules22
07-23-2005, 11:57 PM
I've been using SSI on my site for two years now (I dread it now), and so far it has worked well. But now I'm planning on doing some major upgrades (example: Skin chooser) and for that I need the functionality that PHP provides (i.e. cookies, sessions, etc.). But the problem is that I'm happy with my ratings in Google. If I change my .shtml files into .php I will loose many rankings because of that. What I need is a way to not have to change any file names but still get the function PHP provides..

The two ways I thought of having this done is 1) Redirect all my .shtml files into the .php files. But I've many files and it would be a nightmare. 2) Include PHP files into the SSI using <!--exec cgi=file.php--> I tried it and it seems to work (I tried including a poll into a blank HTML file. I put the PHP code required to include the poll into a php file, than included that php file into an SSI file), but it requires tweakings to PHP scripts and I'm not sure if it will work everytime..

Is there any other way I can do this? And if I were to rename all my .shtml files will I loose rank on Google et al?

Thank you.

Span
07-24-2005, 12:42 AM
Yes, royrules22, if you rename your .shtml files you will loose all your search engine rankings. Not only in Google. It's like starting all over. Even if you use a 301 redirect .shtml > .php it may take up to 6 months to a year to recover from that. Better tweak your PHP, or make (assuming your site is on an Apache server) Apache parse your .shtml files for PHP.

royrules22
07-24-2005, 12:47 AM
No I definatly don't want to start over. Not when the competition now is much more cut throat. So how would I go about getting Apache to do that? And would there be slowdowns and/or would it eat up my bandwith?

Span
07-24-2005, 10:46 AM
You can make Apache parse .shtml files for PHP with this line in your .htaccess:
AddType application/x-httpd-php .shtml
Your pages will be seen as PHP files after doing that, so you can use <?php ?> tags wherever you want in them.

I don't think it will be slower. Before, your pages were parsed for SSI directives, now they are parsed for PHP.
And it won't make any difference in bandwidth usage.

royrules22
07-24-2005, 08:03 PM
With that code would .php files also be parsed as PHP?

Span
07-24-2005, 08:05 PM
Yes, .php files will e parsed as PHP. That line only affects .shtml files.

royrules22
07-24-2005, 10:16 PM
Hmm. I created a test directory, included a .htaccess file with:

AddType application/x-httpd-php .shtml

and than had a .php file and a .shtml file with the same PHP code. The .php file worked perfect but when I try to access the .shtml file in Firefox I get a Save File As dialog and in IE I get a blank page and cannot even access it's source.

Span
07-24-2005, 10:59 PM
Oh, great :( You could try adding one directive:

RemoveHandler .shtml
AddType application/x-httpd-php .shtml

The Removehandler directive overrides the server config so .shtml files are treated as normal files (not parsed for SSI directives anymore), and then the AddType should make the server parse your .shtml for PHP.
If that doesn't work, I don't know. Maybe ask your host?

royrules22
07-25-2005, 12:25 AM
At least it loads something:


Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, ******* and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.33 Server at www.duelingclub.com Port 80

Span
07-25-2005, 12:35 AM
Any info in the error log?

royrules22
07-25-2005, 04:13 AM
Good point. Let me check. I've actually never bothered looking at the server error log

[2005-07-24 22:05:28]: error: file has no execute permission:

Span
07-25-2005, 11:25 AM
There should be a path and a filename at the end of that, but I'm guessing you're not allowed to use an .htaccess? Or not allowed to override the server config? Anyways the only one who can tell you is your host.

royrules22
07-25-2005, 07:53 PM
I asked my host. He stated we can use .htaccess and my CPanel has a setting in which we can change MIME types.