What is Server Side Includes (SSI)?
A Server Side Includes or SSI is a type of an HTML that directs the web server to generate data for the web page whenever it is requested. It helps you do time saving tasks such as accessing and displaying server specific information like the current server time, the visitor’s IP address. It is usually used to insert the contents of another file. SSI is especially useful in insuring the boilerplate components like headers and footer remains the same throughout the web page. It can also be used to execute programs and then insert the results. However, the most basic use of the SSI is it is used to include one or more files into the web browser.
SSI’s basic format takes this form <–#command tag=”value”…> where the value #command can be any or one of the various commands that is supported by the web browser. Its simplest command, which is the #include, is used to insert contents of another file. Though not a requirement, almost all web pages that contain SSI end with a .shtml extension.
How do I tell if SSI is enabled?
To check whether SSI is enabled in your server or if it is active, you may need to do a small test by simply following these steps:
- First, create a new HTML document and you may name it test.shtml. For its coding, enter the following code:
o It is essential that you copy everything correctly including the spacing.
o Do not forget to use the “s” in the .shtml in the file name extension as it is a very important factor for it to work correctly. The “s” stands for Server, which basically tells the host server that the page requires special attention since it is using a special function. Not all host servers, though, require the use of the extra letter but some do. Anyway, as it does not hurt its performance even if it is not needed, so better put it in since you don’t know if the host needs it or not.
- After making sure that everything is correct, upload the page to your online area and then view it. SSI is enabled in your system if you will see the current date displayed.
- But if your system displays a blank page, it means that SSI is not yet enabled.
How to enable SSI in my Apache web server?
There are a number ways of enabling SSI, that is depending upon the server you use. Of you are using Apache, you may enable it by editing the httpd.conf file of Apache:
- First, you need to have access to Apache’s main configuration file named httpd.conf and enable SSI simply by adjusting some of its settings. To find the httpd.conf file, you may need to check on these locations:
(For Linux) /etc/httpd/conf/httpd.conf
(For MacOS Leopard and Snow Leopard) /etc/apache2/httpd.conf
- Once accessed, look for these lines #AddtType text/html.shtml
- Uncomment these lines by deleting the # before the AddType and AddHandler.
- Then, make sure that the DirectoryIndex setting has included the index.shtml and may look like this:DirectoryIndex index.shtml.html
- Restart the Apache and SSI should now be enabled on your system.
Can I enable SSI on Windows?
You can enable SSI on your Windows server through Windows IIS. However, only the server administrator can turn it on. To do it, you need to go to the “Web Service Extensions” and then you need to set the server side includes to “Allowed”. Then, in the IIS Manager, open the local computer then right-click on the “Web Sites” folder and click on “Properties.” Make sure that the default content page list in the “Documents” tab includes the index.shtml.