KB 456

From SWCP Support Wiki
Revision as of 11:36, 4 June 2008 by Jamii (talk | contribs) (New page: ===How do I use Server Side Includes=== Article:456 Created:2007-03-17 14:18:20 Categories: Web Publishing Sys Admin ====Question or Symptom==== You want to know what Server Si...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

How do I use Server Side Includes

Article:456
Created:2007-03-17 14:18:20
Categories:
  Web Publishing
  Sys Admin
 

Question or Symptom

You want to know what Server Side Includes (SSI) are, and how do you use them on your website hosted at SWCP.


Resolution

SSI (Server Side Includes) are directives that are placed in HTML pages, and 

evaluated on the server while the pages are being served. They let you add dynamically generated content to an existing HTML page, without having to serve

the entire page via a CGI program, or other dynamic technology.
 

The decision of when to use SSI, and when to have your page entirely generated by some program, is usually a matter of how much of the page is static, and how much needs to be recalculated every time the page is served. SSI is a great way to add small pieces of information, such as the current time. But if a majority of your page is being generated at the time that it is served, you need to look for some other solution.

Some common, easy to use SS directives are:

  To display the current date in the page.
 To display the modifcation date of a file.
  Usually used to include something that 

repeats on many pages, such as a standard hearder or footer.

For the SSI to work, the HMTL file must end in .shtml, as in example.shtml.

SSI can also be used to execute an external CGI script and display the output. To use this feature with SWCP web hosting you must do 2 things. First, you must use the "include virtual" syntax.


Second, you must put the script in your cgi-bin directory, and call it with your script alias, just like you would call a CGI script from a form. For example, user johndoe wants to use SSI to execute the script cutequote.pl. He would put the script in /users/johndoe/public_html/cgi-bin. Then in his web page, he'd use this: