Gossamer Forum
Home : General : Perl Programming :

SSI and file extensions

Quote Reply
SSI and file extensions
Hi All-

In the process of adding SSi to my static (non-links) pages I realized that I'll be hit in the rankings department if I have to use a bunch of redirects to send visitors to the new pages with the shtml extensions. I hear that you can still have ssi using regular html file extensions using php. I've tried adding htis to .htaccess and no luck each way:

Options +Includes
AddType text/html .shtml
AddHandler server-parsed .shtml
AddType application/x-httpd-php .htm .html

and


Options +Includes
AddType text/html .htm .html .shtml
AddHandler server-parsed .shtml
AddType application/x-httpd-php .htm .html .shtml
AddOutputFilter INCLUDES .html .htm .shtml

and using this call:
<?include "includes/header.php" ?>

any ideas?
the object is to just keep all my original files

thanks much!
Quote Reply
Re: [SSmeredith] SSI and file extensions In reply to
Should work with;

AddHandler server-parsed .shtml .html .htm

That way, all .shtml, .html and .htm files should be processed as SSI pages (just like a .shtml page would).

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] SSI and file extensions In reply to
   
hi Andy,

so, given the codes i've shown, and making the change you suggested, which set to use?
Quote Reply
Re: [SSmeredith] SSI and file extensions In reply to
I would be enclined to just keep using the old extension, and just modifying the type that they are run by (i.e if you old ones were .html, and you wanted to change to .shtml for SSI purposes, then just keep .html, which saves SEO problems, and add the code I provided above in a .htaccess file, so that .html and .htm pages are parsed as SSI too).

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [SSmeredith] SSI and file extensions In reply to
  So I need to just add this code in the .htaccess file?

Options +Includes
AddType text/html .shtml
AddHandler server-parsed .shtml .html .htm
AddType application/x-httpd-php .htm .html

By the way, my .htaccess file is blank now, must have got a trashed respoinse and emptied it. Is there anytyhing that should be in there by default? I saw some Frontpage junk but don't need that anyway, and can't remeber what else. Except when I visit the domain to check and see if the file is working it's prompting for download. Weird...

Ahh, one of those morningsMad

Last edited by:

SSmeredith: Jun 10, 2004, 7:07 AM
Quote Reply
Re: [SSmeredith] SSI and file extensions In reply to
it's the code i added, it's prompting for the file on the local drive.

still not working, the include doesn't show up...

Last edited by:

SSmeredith: Jun 10, 2004, 7:54 AM
Quote Reply
here's the error In reply to
Warning: main(includes/header.php): failed to open stream: No such file or directory in /home/contclub/public_html/associations.htm on line 17

Warning: main(): Failed opening 'includes/header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/contclub/public_html/associations.htm on line 17



Andy, it was the line that you gave me that was causing the download prompt.

Last edited by:

SSmeredith: Jun 10, 2004, 8:28 AM
Quote Reply
Problem Solved In reply to
For anyone who wants to use server side includes on their site without having to change all the file extensions to .shtm or .shtml and you run Apache you can use php. Not to confuse, these aren't used on links pages. Check the other forum topics, as there is more info about adding includes to GT products.

(Note: Please look into the potential slowness of parsing the whole page. For me it's not a big issue as these aren't very busy pages as most of our traffic is on Links SQL pages.)

After many attempts and different include tags and codes- this is what worked for me and how to do it

1) Create an html file for header and/or footer or whatever else you want to include like a side nav,etc. Then rename the file with a .php extension. I'll use header.php

2) Next, paste this code where you would want the header to appear:

<? include 'header.php';?>

You must remember that the header.php file must reside in the same place as the file you have added the code. If you have files in subfolders you can use an absolute path such as this:


<? include("http://www.mydomain.com/header.php"); ?>



3) Lastly, in your .htaccess file on your server paste this code:

Options +Includes
AddType application/x-httpd-php .htm .html


View the file in your browser and you should see the include appear.

Troubleshooting: If you see a bunch of errors on the page, that means the include is parsing the file, or trying to, so you need to recheck your paths and check the code in the .htaccess file. If you don't see the include appear and with no errors, check your source code from the browser and see if the tag is there. If you see it, that means that the file is not being parsed and you need to recheck your include code.

Time spent troubleshooting code: 1 week
Time adding code to pages: 14 days
Time saved in the long run: Priceless
Wink

Hope this helps, but I'm not very technical, just relentless and any mistakes here are my own. Blush
Quote Reply
Re: [SSmeredith] Problem Solved In reply to
Hello SSmeredith,

I think what Andy was trying to say was that you don't need PHP to use SSI.
I have more than half a dozen sites using SSI and none of them are using PHP (...yet Wink) and I never use the .shtml extension.

The line he gave you instructed the web server to parse .html and .htm as well as .shtml for any SSI directives without the need for PHP.

You can then include files this way:
Code:
<!--#include virtual="/path_to_includes_folder/name_of_included_file"-->
For example:

<!--#include virtual="/includes/header.inc"-->

This will look for the file named 'header.inc' in the "includes' folder from the root of the site.

I tend to use the .inc extension for included files so that they are not parsed for directives (unless they need to be in which case I use .htm or .html).

Of course, you may need PHP for other reasons (it is pretty cool after all...) but if all you need to do is include files, then I would stick with the built-in SSI support that Apache has.

Enjoy.