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
6
votes
5 answers

PHP - Split code into multiple files or keep it in as few files as possible?

Right now I have a script that has reached 400 KB in 4 files (about 3500 lines per file). Should I split it into more files? Does having more files have a impact on performance because of multiple require_once calls?
Alex
  • 66,732
  • 177
  • 439
  • 641
6
votes
5 answers

SSI #set variable and #echo issue

I have a simple .shtml file that I have declared a variable in it. But when I want to print the value using it says Variable 'testVar' cannot be found What's the problem? I'm…
David Weng
  • 4,165
  • 12
  • 42
  • 51
6
votes
4 answers

How to refresh #include files - they are caching on IIS7 / ASP.NET

I have an ASP.NET master page which references a #include file as follows: I have modified the file /includes/scripts.inc but the changes do not show up in pages. What needs to be done so…
frankadelic
  • 20,543
  • 37
  • 111
  • 164
6
votes
1 answer

Use web.config to allow server-side includes in HTML files (IIS)

In IIS 7.5, is it possible to use web.config alone to enable SSI processing for files that have the .html extension? Specifically, I don't want to use the default SSI extension, .shtml. Reason: I don't want to change the extensions. Doing so would…
Trojan
  • 2,256
  • 28
  • 40
5
votes
4 answers

PHP Check If require_once() Content Is Empty

I am working on a PHP script which involves me including several external PHP scripts via the "require_once()" method. I would like to know if there is a way for the master script (the one including the others) to tell whether or not the processed…
Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
4
votes
2 answers

Server Side Include on S3

Amazon S3 has static website hosting, but does not support tags like: Is there anyway to mimic this functionality without having some sort…
dgxshiny
  • 107
  • 1
  • 6
4
votes
4 answers

Design Tips for PHP Function Include Files

Good design dictates only writing each function once. In PHP I'm doing this by using include files (like Utils.php and Authenticate.php), with the PHP command include_once. However I haven't been able to find any standards or best practices for…
C. Ross
  • 31,137
  • 42
  • 147
  • 238
4
votes
2 answers

WebMatrix parse .html file as .asp

I have a file with .html extension that contain the: directive and I'm using Microsoft WebMatrix. When I run the web pages from WebMatrix the directive isn't processed and instead the directive shows up in the…
Brian Fisher
  • 23,519
  • 15
  • 78
  • 82
4
votes
0 answers

Is it possible to use Angular for Server Side Includes (SSI)?

I have little to no experience with Server Side Includes. I have read on the internet that you can work best without libaries/frameworks if you work with Server Side Includes. To avoid dependencies. But I am still curious what the possibilities are…
Undeadparade
  • 1,512
  • 2
  • 14
  • 30
4
votes
3 answers

server-side includes and character encoding

I created a static website in which each page has the following structure: Common stuff like header, menu, etc. Page specific stuff in main content div Footer In this website, all the common content is duplicated in each page. In order to improve…
Dónal
  • 185,044
  • 174
  • 569
  • 824
4
votes
2 answers

Include a file into a variable

I am trying to keep my code clean break up some of it into files (kind of like libraries). But some of those files are going to need to run PHP. So what I want to do is something like: $include = include("file/path/include.php"); $array[] =…
jefffan24
  • 1,326
  • 3
  • 20
  • 35
4
votes
2 answers

Is SSI still relevant?

On my work i can see old sites using SSI to include huge parts of code and do some conditional work. I'm just curious is SSI still developing? If not, what modern simple server-side scripting languages exist?
vtambourine
  • 2,109
  • 3
  • 18
  • 27
4
votes
2 answers

php includes not working with relative path - DocumentRoot issue? MAMP?

There has to be something I'm overlooking but I can't seem to get my includes to work as expected using relative paths. In MAMP the DocumentRoot is configured in httpd.conf like this: # MAMP DOCUMENT_ROOT !! Don't remove this line !! DocumentRoot…
Russ M
  • 41
  • 3
4
votes
3 answers

Problems with Server-side Includes

I desperately want to use server-side includes in a project I'm working on because I just have some HTML that repeats and I need to get it on several pages. Must I use ascx or some other include technology... I mean, will lightning strike if I use…
Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
3
votes
2 answers

Can $_SERVER be faked in PHP?

In PHP, Remote file inclusion can be conducted via input from $_GET, $_POST, $_COOKIE. I know it is improbable, but is it possible (by any chance) to fake the value come out of $_SERVER? I mean, can $_SERVER become the source of Remote file…
Googlebot
  • 15,159
  • 44
  • 133
  • 229
1
2
3
15 16