Server Side Includes
Server Side Includes are a standard feature of the Apache web server which allows for HTML files to trigger special events when accessed via the web server. Please note that only files with extensions of ".html" or ".htm" are scanned by the web server for these include statements. The full list of possible actions can be found via the main Apache website but some common examples are included below.
To tell Apache that you want to use SSI you need to create a .htaccess file in the web folder that has the following content:
Options +Includes
AddHandler server-parsed .htm .html .shtml
Including a File
By using a special directive, you can make the web server automatically insert another file into the middle of a web page on the fly. For example, you can include a common footer on all of your HTML pages by using a directive similar to this:
If you need to include a PHP script or a file in another directory, you can use the "virtual" action instead which simulates a new page load in Apache:
Showing an Environment Variable
Environment variables are system set values which are accessible by Apache. These include things such as the current date, the IP address of the machine that requested the page and the name of the file being accessed and displaying these can be useful in many situations. To display a specific environment you need to use the "echo" directive:
For a more detailed discussion of environment variables please refer to our Apache Environment Variables documentation.