Questions tagged [server-side-includes]

Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the Web.

The most frequent use of SSI is to include the contents of one or more files into a web page on a web server. For example, a web page containing a daily quotation could include the quotation by placing the following code into the file of the web page:

<!--#include virtual="../quote.txt" -->

With one change of the quote.txt file, all pages including the file will display the latest daily quotation. The inclusion is not limited to files, and may also be the text output from a program, or the value of a system variable such as the current time.

Server Side Includes are useful for including a common piece of code throughout a site, such as a page header, a page footer and a navigation menu. Conditional navigation menus can be conditionally included using control directives.

In order for a web server to recognize an SSI-enabled HTML file and therefore carry out these instructions, either the filename should end with a special extension, by default .shtml, .stm, .shtm, or, if the server is configured to allow this, set the execution bit of the file.

As a simple programming language, SSI supports only one type: text. Its control flow is rather simple, choice is supported, but loops are not natively supported and can only be done by recursion using include or using HTTP redirect. The simple design of the language makes it easier to learn and use than most server-side scripting languages, while complicated server-side processing is often done with one of the more feature-rich programming languages. SSI is Turing complete.

Apache, nginx, lighttpd and IIS are the four major web servers that support this language.

SSI has a simple syntax: <!--#directive parameter=value parameter=value --> Directives are placed in HTML comments so that if SSI is not enabled, users will not see the SSI directives on the page, unless they look at its source. Note that the syntax does not allow spaces between the leading "<" and the directive.

236 questions
0
votes
1 answer

Apache > Setup Server Side Includes > OSX Snow Leopard > Still Not Working

I have researched this for about 2+ hours including 1+ hour of preparing this report (I must be a slow worker, considering I haven't slept in 24 hours :-P) The virtual server side include works in Dreamweaver (except for image rendering), but does…
Dave Kirkby
  • 409
  • 1
  • 4
  • 14
0
votes
1 answer

RegisterClientScriptBlock CDATA inline declarations

I'm moving significant amounts of header includes into codebehind when migrating from aspx pages into ascx controls, I've been wrapping them in RegisterClientScriptBlocks and using linq to keep the large multiline tidy. However have noticed that…
0
votes
2 answers

Is it possible to have randomness in server-side includes?

I want to introduce some random* behavior into an otherwise static html file. I want to experiment with two different advertising schemes, and I want to have the page erved randomly with either one or the other. It seems like overkill to use a…
pkaeding
  • 36,513
  • 30
  • 103
  • 141
0
votes
1 answer

PHP include a file at subdomain from main domain on a different server/host

I have this php www.example.com/template.php and would like to include it in a index.php file at sub.example.com/index.php and this sub-domain is on a different server with a different host. Please advice.
user1170540
0
votes
3 answers

simple PHP script creates error

Let me make it nice and simple: as probably everybody else, I am using simple includes on the server for various things such as top menu or a side menu and so on... Here is my example of code
AlexB
  • 2,164
  • 6
  • 27
  • 61
0
votes
2 answers

Custom variable which can be used on each page like super globals?

I want a variable to be superglobal, but as am using procedural style I don't think I can make one of my own, so basically the question is that am using a query to retrieve all security control of my website from security table, am checking whether…
Random Guy
  • 2,878
  • 5
  • 20
  • 32
0
votes
3 answers

How to get project root directory in php with user friendly URL

I created initialize.php to define my project's root directory. defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_ROOT') ? null : define('SITE_ROOT', DS.'works'.DS.'myproject'); I include it with something like this from any…
0
votes
2 answers

HTML Include file

I have a basic web application packaged as an EAR deployed on GlassFish. The web module has some html files. The html files have a common footer, an html file, that I would like to extract out and make an include. When I do, and put: