Server Side Includes

Tired of updating navigation for every pages? You tried Frameset, but it's not so accessible. Using server-side scripting is the best way to maintain accessibility and interactivity. Server-side include is part of server-side scripting.

Webhost Requirements(you only need one of them, click one of the link to continue)

  1. Apache HTTP Server/CGI
  2. PHP
  3. ASP/ASP.NET

SSI with .shtml

To SSI on Apache(with/withoutout PHP/CGI), add the following comments to include:

<!-- #include virtual="include.inc"-->

Then include.inc's content will appear on the page that used the #include. Sometimes you must rename it to *.inc, and sometimes *.html.

If it doesn't work, your host may not support it, or add this .htaccess file:

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

ASP/ASP.NET also have SSI, but it seems that it requires *.inc as file extension on included files.

PHP SSI

PHP has their own include feature. It's not #include, it's the include() function.

<?php
include ('navigation.php');
?>

The file to be included must have *.php as extension. PHP functions can also be included by using SSI.

Links & Resources

  1. PHP include()
  2. PHP require()
  3. Enabling SSI Via htaccess


Comments

Add Comment