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

Apache: SSI inside SSI

Is there a way I can include include files inside include files? (Say that five times fast!) For example: Inside index.html: Inside include1.shtml: So the tree…
neezer
  • 19,720
  • 33
  • 121
  • 220
3
votes
1 answer

Can you run server-side includes on a Python SimpleHTTPServer? If so, how?

I want to use server-side includes so I can include header and footer files on my personal portfolio. I've been using the Python SimpleHTTPServer because I had the command handy, so I know how to run it. My server-side includes don't currently work.…
user422318
  • 191
  • 3
  • 3
  • 11
3
votes
4 answers

What is the right path for PHP includes on a Mac?

Running Mac OS X 10.5.8, with PHP 5.2.11 Pre-installed. Using Coda 1.6.10. I'm writing PHP files, and then preview them running from file, not server. This was working fine till I tried PHP includes. These don't work as a relative path, only as an…
Neil
  • 3,100
  • 5
  • 29
  • 36
3
votes
1 answer

Server Side Includes Not Working on Windows 2008/IIS 7

We have a Windows 2008 web server running IIS7 and cannot seem to get ServerSideIncludes to work despite following all the instructions we could find. Here are the steps we have completed: Enabled SSIs in IIS 7 Confirmed ServerSideIncludes was…
KenP
  • 61
  • 2
  • 4
3
votes
2 answers

ASP.net code within include not executing

It's been a long time since I dabbled server-side, but it seems to me that scripts embedded in an included code file should execute as normal. This doesn't seem to be the case for some reason. (Note-- The below is obviously a simplified…
sdowswell
  • 101
  • 12
3
votes
2 answers

How to include contents of plain HTML or classic ASP file in an ASP.net MVC 3 view?

I'm working on an ASP.net MVC 3 application. I have an external classic ASP file that renders a fragment of a page. I understand that in ASP.net MVC 3, I can define a partial view to contain a fragment of HTML that I want to reuse on multiple…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
2
votes
3 answers

Where should PHP files for includes and PHP files for for AJAX calls go on the server?

I have a site that uses a number of includes (for footer, email processing, etc.). I am also using AJAX, which calls a particular URL to load the data. I am a little confused as to where these files should be located on the server. I assume that,…
Ken
  • 3,091
  • 12
  • 42
  • 69
2
votes
2 answers

Why isn't #Include working on .asp page on IIS7?

SYMPTOM: I have Test_virtual.asp with the following:   included content starts here: test_included.txt contains only: This is the included file When I browse to test_virtual.asp, I…
Clay Nichols
  • 11,848
  • 30
  • 109
  • 170
2
votes
3 answers

ASP.NET Directive Convention for Declaring Client-Side Includes

I am loading .aspx and .ascx files as StreamReader. I want each file to register it's javascript and stylesheet dependencies in some declaration like a <%@ ClientDependency path="~/Scripts/jquery-1.4.1.min.js" %>. Is there an existing convention…
2
votes
1 answer

Does traefik do server side includes?

Kubernetes Ingress Nginx can do server side includes by allowing Server snippets. https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-snippet While, traefik doesn't appear to support server side includes…
2
votes
2 answers

Server Side Include - php

I'm updating a site that is currently static html (i.e. index.html). I'd like to pull in blog posts into the page and only know of SimplePie to accomplish this. Question 1 - If I update the site from .html to .php is there a hit in SEO while the…
2
votes
3 answers

Scanning directory for php files, and include them in the current script

Would it be a good idea to include extensions for a script this way? for eg. using glob to get a list of php files from a certain directory, and do a require_once for each file. this would run each time the page is generated. would it be bad for…
Alex
  • 66,732
  • 177
  • 439
  • 641
2
votes
4 answers

Server side include breaks layout

I have finally perfected my web page and it works perfectly in every browser. However, when I abstracted out the header and footer contents into server side includes, the layout changes marginally in Firefox/Opera/Safari, but in IE, the layout…
Moses
  • 9,033
  • 5
  • 44
  • 67
2
votes
1 answer

server side include not working for nested calls

I using server side includes to organize my files. The nested files do not seem to work. For eg:- index.shtml - this works fine This is not working. I am using WebStorm IDE by JetBrains I tried adding .htaccess file # Enable server side includes Options +Includes # pass .html files to…
Stacy J
  • 2,721
  • 15
  • 58
  • 92
1 2
3
15 16