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
2
votes
4 answers

include_path doesn't recurse?

I have several separate websites that live in separate directories. For includes that they have in common, I have it living in the root directory where the rest of them live. user@hostname:/var/www$ ls website_1 website_2 website_3 common_files I…
user151841
  • 17,377
  • 29
  • 109
  • 171
2
votes
1 answer

passing array parameters to smarty PHP template include

On a PHP site using the smarty template engine (or at least a close relative of smarty), I am calling a template include file ("header.html") which contains this code excerpt, along with other HTML omitted here for…
Justin Grant
  • 44,807
  • 15
  • 124
  • 208
2
votes
2 answers

Going back to 1990's... how to get this SSI to stop throwing a directive error?

There is incredibly little documentation on how SSI directives work! But I'm following very simple examples and can't seem to adjust them to my purposes without throwing an error. What I want to do is display a custom 404 that differs based on if…
bcsteeve
  • 973
  • 9
  • 22
2
votes
3 answers

including other pages in HTML documents

Let say you are working on a website template that has many pages (index.html, blog.html, contact.html...). You start by designing the home page and then move on to other pages. While you are on other pages, you think of some improvements and these…
Omar Abid
  • 15,753
  • 28
  • 77
  • 108
2
votes
4 answers

ASP.NET - Missing #includes cause compilation errors: Failed to map the path '...'

I have an ASP.NET application which features some server-side includes. For example: These files are not present in my ASP.NET website project because my website starts in a virtual…
frankadelic
  • 20,543
  • 37
  • 111
  • 164
2
votes
1 answer

Server side includes on app engine ()?

I have been trying to figure this out a while. I would like to make my app engine website use basic html and shtml whenever in order to avoid the slow warm-up phase of jsp apps on app engine. This is so that my landing pages load…
Anon21
  • 2,961
  • 6
  • 37
  • 46
2
votes
4 answers

A way to edit content by altering one file?

I have a contact css tab on my left side on my website, I have more then 30 pages and I don't wantto manually alter all those pages later when data had changed. Does anyone knows a sollution so I only have to alter 1 file to have all pages…
Chris
  • 1,919
  • 6
  • 34
  • 60
2
votes
4 answers

Including files with HTML in Node.js

I can't seem to figure out how to include a file using Node.js. All of the other questions seem to discuss including other JS files, but I'm looking for the equivalent of a PHP include (files that can contain HTML content). Usually in PHP, my view…
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
2
votes
1 answer

PHP: Is 200 file includes too much for a website?

I have here a custom made CMS (based upon MVC and made by somebody else) and it includes a massive amount of 200 files (896kb total source size and a peakmem usage of 7MB) on each request. Memory usage is OK but it is quite large amount of files if…
Codebeat
  • 6,501
  • 6
  • 57
  • 99
2
votes
2 answers

WAMP + PHP CSS Include wont update with new styles

I am stumped. I am using includes to import a style sheet. If I add a new style to the style sheet, generated pages will not display ANY of the new css. If I change an old css rule it WILL display the change. I thought it might be a cached file…
2
votes
2 answers

Including HTML fragments in a page - methods?

This is an extension of an earlier questions I asked, here: Django - Parse XML, output as HTML fragments for iFrame? Basically, we're looking at integrating various HTML fragments into a page. We have an small web app generating little fragments for…
victorhooi
  • 16,775
  • 22
  • 90
  • 113
2
votes
3 answers

Can't get Server Side Includes (one HTML file into another) to work

I can't get server side includes to work. I simply want to include one html file into another and I just can't seem to get it working Setup The server is a another machine (not localhost) running Windows XP. I've got a slighly older version of the…
BlueShepherd
  • 593
  • 3
  • 12
2
votes
2 answers

ASP - Determine if current Script is being run as an include

Lets say I have the following pages: # Include.asp <% Response.Write IsIncluded() & "
" %> # Outside.asp I need this to work such that if I access http://Example.com/Include.asp directly, I see "True", yet…
Tristan Havelick
  • 67,400
  • 20
  • 54
  • 64
2
votes
1 answer

Apache SSI and variable

I've got a 10 year old Apache server (FreeBSD) where the following works: File1.htm File2.htm //sets myDir //loads…
DougN
  • 4,407
  • 11
  • 56
  • 81
2
votes
2 answers

How to make redirect if HTML-document doesn't exist on server

How to make redirect to 404 or root page when user types query to not existing page and SSI include gets error? Or how to check if HTML-document exist on server and if doesn't then also make redirect? If user types domain.tld?anyquerystringon my…
andrew
  • 426
  • 8
  • 18