cancel
Showing results for 
Search instead for 
Did you mean: 

Server Side Includes (SSI)

mindwarp
Newbie
Posts: 4
Registered: ‎20-02-2010

Server Side Includes (SSI)

Hi,
I am fairly new at web site coding, the first attempt wasn't ideal, so now I am trying to "revamp" my website with a little more understanding.  I want to use server side includes (SSI) and tried this out with one of my pages (not linked to the rest of the site at the time) - the include worked (for a nav. menu to the left of my page).  So I carried on working on the pages locally to change them all to use an include instead of copying the nav menu to each one.  So far so good.  I then went back to check what version of the test page was in place on plusnet and found that the include had stopped working.  It did wonder if it was me changing something, but my wife was sat by me at the initial eureka moment when it worked!!
So after looking at it for some time and failing for the include to work again, I tried a really simple skeleton of a page and this also fails.
At this point logged a ticket and waited for a couple of days and now have a response that it "...appears to be an issue with the framing/code of your page ...".  Which is less than helpful.
So I tried to test with a free web site hoster and the exact same code works there...
The simple skeleton is :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<p>
this is the body - some text should appear after here<br>
<b><!--#include virtual="/test.shtml" --></b>
</P>
</BODY>
</HTML>

The  test.shtml only has this line in it:
 This is the included text<br>

Can anyone please shed some light on this?  especially as it has worked on PN & does work on another host site!?
Many thanks
13 REPLIES 13
Midnight_Caller
Rising Star
Posts: 4,167
Thanks: 15
Fixes: 1
Registered: ‎15-04-2007

Re: Server Side Includes (SSI)

Is the file as php or html ?
Is this on:
http://www.username.f9.co.uk
http://www.username.plus.com
Thay are the home pages server, you can not run php on them only html.
You can run  php on:
http://ccgi.username.force9.co.uk
http://ccgi.username.plus.com
http://username.plushost.co.uk - Both
mal0z
Grafter
Posts: 3,486
Registered: ‎02-10-2008

Re: Server Side Includes (SSI)

The server needs to be set to run includes - is it ?
Personally I rarely use html includes but use php on all pages.
But the code looks ok.
best by the way not to put n include inside other tags like the bold one you have, put all the code in the include file
mindwarp
Newbie
Posts: 4
Registered: ‎20-02-2010

Re: Server Side Includes (SSI)

Hi thanks for the quick replies!
The file is html and is in my htdocs folder under www.username.f9.co.uk (well under the domain that PN is hosting for me).  The include file is shtml.
Does the 'include' tag count as code?  I was under the impression from what I have read that it is simply a directive to the server - or maybe I have got the concept wrong..!!
Do I need to move all my pages that use an include to the CCGI.username.f9.co.uk ?  If so how do I get the index.html to pass control over - a redirection would be necessary wouldn't it?!?  Unless there is another way to "include" repetative parts of the page so that I only have to type nav menu in once?
From what I can gather (& I was hoping to confirm this with my ticket, but that hasn't happened) the server is set to run includes (http://usertools.plus.net/tutorials/id/5 & http://community.plus.net/forum/index.php/topic,69283.0.html).
I have found a post from 2004 that explains how to do this, but even following this I can't seem to get any joy!
I am not sure if I really need a ".htaccess" file at all.
Good point on the include inside other tags, just wanted to make it stand out - was getting rather frustrated as I typed it!!!
Cheers,
Midnight_Caller
Rising Star
Posts: 4,167
Thanks: 15
Fixes: 1
Registered: ‎15-04-2007

Re: Server Side Includes (SSI)

shtml will not work on home pages server it must be html or htm to work on the home pages server.
mal0z
Grafter
Posts: 3,486
Registered: ‎02-10-2008

Re: Server Side Includes (SSI)

Well yes - the include is code of a sort - inside comment tags  - but is stripped out by the server when it parses the file, so you won't see it on the final code sent out by the server to the browser.
I'm sorry I don't know how the cgi server works, I just don't bother with such systems, I have an proper Apache, php. mySQL, as provided by PN on their PAYH sister company and most proper hosting companies !. On those systems all the code in in the same server, much easier.
Gabe
Grafter
Posts: 767
Registered: ‎29-10-2008

Re: Server Side Includes (SSI)

For the homepages platform, create a .htaccess file and add these lines
AddType text/html .shtml
AddHandler server-parsed .shtml

Gabe
edit: having read your second message again, the included file doesn't need to be .shtml. It could be .txt. If you want .html files treated as .shtml, then replace .shtml with .html in the above.
mindwarp
Newbie
Posts: 4
Registered: ‎20-02-2010

Re: Server Side Includes (SSI)

Finally!!  Have sorted it out  Cheesy
Many thanks to all here for assistance. Smiley    No thanks to plusnet "formal" support. Angry
This post - http://community.plus.net/forum/index.php/topic,53020.0.html/ - helped as well.  I think it was a combination of things that I was doing wrong/not understanding properly.
The key was thanks to Midnight Caller & Gabe - that on the homepages you HAVE to use only htm or html.  Once I had made the .htaccess with this info in it, the nav. menu appeared properly.  For anyone else who stumbles across this thread this is the .htaccess I used :
AddType text/html .shtml
AddHandler server-parsed .shtml
AddHandler server-parsed .html

Have just tried it out with simple .txt extension and this works as well.  From what I had read, I thought that the include file MUST be shtml (or equivalent).
@mal0z - quite agree that 'proper' hosting should be done on one server.  This seems a very convoluted way to achieve things.
The PN support has been abysmal on this one, coupled with the lack of coherent documentation.  Some of the links to cgi information are STILL talking about SSH when this has been turned off for over six months.
Once again thanks for all the replies.
Cheers!
Midnight_Caller
Rising Star
Posts: 4,167
Thanks: 15
Fixes: 1
Registered: ‎15-04-2007

Re: Server Side Includes (SSI)

Your welcome just shout up if you need any more help.
And welcome  to the forum.
mal0z
Grafter
Posts: 3,486
Registered: ‎02-10-2008

Re: Server Side Includes (SSI)

As Gary says - your most welcome.
I hope that one day PN will revamp their PAYH products and integrate them more fully into PN
Gabe
Grafter
Posts: 767
Registered: ‎29-10-2008

Re: Server Side Includes (SSI)

Just to clarify:
SSI does work (with certain limitations) on the homepages server. The extension does not have to be .html or .htm.
Actually, to use the .shtml extension on homepages, you don't even have to add a type, just a handler. The advantage of not using .html for server-parsed files is that if you do, all your .html files run through server parsing, whether they contain includes or not, and that's a bit inefficient.
If you did want to hide the fact that you're using includes, you could use a custom extension by adding both a type and a handler:

AddType text/html .foo .bar
AddHandler server-parsed .shtml .foo .bar

Then you could use any of the options with a server-parsed handler. NB, the file containing the include needs an extension with a server-parsed handler; the file to be included doesn't.
Note on ccgi and PAYH:
On ccgi, you can have all your code on one server. PAYH has a number of disadvantages relative to ccgi. At the moment, it has two notable advantages relative to ccgi: one called Cron and one called Kev.
Gabe
edit: corrected typo
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: Server Side Includes (SSI)

Quote from: Midnight
shtml will not work on home pages server it must be html or htm to work on the home pages server.

That my website on homepages which consists of mainly shtml pages has been working for the last few years must be a figment of my imagination!
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
mal0z
Grafter
Posts: 3,486
Registered: ‎02-10-2008

Re: Server Side Includes (SSI)

I just avoid all those little complications by just using php includes,
and all pages on my sites have .php extensions, and all include files are like:
example.inc.php
the inc reminds me it is a n include, and the php means all the code goes through the php engine.
Makes life much simpler.
you don't need to learn the more complex php code, i started on just a few to begin with.
I've never regretted learning some php, it compliments html/css very well.

mindwarp
Newbie
Posts: 4
Registered: ‎20-02-2010

Re: Server Side Includes (SSI)

@jelv - Which makes me wonder all the more about what has happened since my initial test page.  I used my "aboutus" web page, called it directly with a url (before I "burnt my bridges & replaced my index.html) & used an include to have a .shtml file put the navigation menu in place.  It worked (for a couple of days) then stopped.  Fair enough, I was testing other things, such as a contact form that hides the email address, and that "just worked".  But I *really* don't remember changing the aboutus & css or doing anything that I thought might have affected the include.
Thankfully it is all working now & the new website has been moved into place, so long as I don't try anything too ambitious and stop it working again...!!
Really appreciate the help from the people on this forum - I still have a few strands of hair left at least  Wink