Landon Noll looking up Fremont Peak Observatory 0.8m telescope Leonid 2001 meteor squall count at Fremont Peak
custom search of Landon Noll's web sites

Server Side Include

[chongo's home] [Astronomy] [Mathematics] [Prime Numbers] [Programming] [Technology] [contacting Landon]


Web Server Configuration

On this Apache server, we have enabled limited Server Side Include (SSI) by the following Apache Options directive inside a Directive directive that controls this part of the web site:
<Directory "../ssi">
...
Options IncludesNoExec ...
...
</Directory">
NOTE: We used the IncludesNoExec directive instead of Includes. By using IncludesNoExec (and not Includes) we disable execution of commands such:
<pre;>
<!--#exec cmd="some_program" -->
</pre>
For the sake of security, the above HTML will cause the Apache server to execute some_program because we use the IncludesNoExec directive instead of Includes in our Apache server configuration.

By default, the Apache server will perform SSI only on files that end with the .shtml file extension. This web page is SSI processed because the filename is index.shtml and not just index.html.

Refer to the Apache Tutorial: Introduction to Server Side Includes for deailed informaton about configuring Apache for SSI.

Simple File Include

Assuning your web server has been configured for SSI (see above), you can cause the server to include the contents of another file in the middle of your html document.

For example, we can include the contents of our robots.txt file by adding the following SSI directive into our HTML file:

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

Our robots.txt file is located at the top of our document root, so we used the path /robots.txt.

Here we insert the contents of the /robots.txt file in the middle of this web page by using the above mentioned SSI directive:

-- before the #include directive --
User-agent: * Disallow: /.ps Disallow: /.tri Disallow: /cgi-bin Disallow: /chongo/jpg Disallow: /chongo/png Disallow: /chongo/tmp Disallow: /dont Disallow: /err Disallow: /favicon Disallow: /no.index Disallow: /site Sitemap: http://www.isthe.com/.sitemap.xml.gz User-agent: W3C-checklink Disallow: User-agent: Mediapartners-Google Disallow:
-- after the #include directive --

Of course, the above include was formatted by the browser. If you wanted to include the file without formatting, then use:

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

Example:

User-agent: *
Disallow: /.ps
Disallow: /.tri
Disallow: /cgi-bin
Disallow: /chongo/jpg
Disallow: /chongo/png
Disallow: /chongo/tmp
Disallow: /dont
Disallow: /err
Disallow: /favicon
Disallow: /no.index
Disallow: /site

Sitemap: http://www.isthe.com/.sitemap.xml.gz

User-agent: W3C-checklink
Disallow:

User-agent: Mediapartners-Google
Disallow:






© 1994-2022 Landon Curt Noll
chongo (was here) /\oo/\
$Revision: 8.1 $ $Date: 2022/07/07 23:48:26 $