Bobcares

Activate SSI Apache | Configuration setup

by | Sep 12, 2022

In this article, we will take a deeper look at how to Activate SSI Apache. Bobcares with help of our Server management support services will give you in a detailed note about SSI (Server Side Includes).

 

How to Activate SSI Apache?

 

The Server Side Includes (SSI) allows you to add files apart from header files on your web pages. They are mainly used to serve dynamic content on web pages and used to reuse HTML codes. For example, you can create a navigation bar/footer for your website, put it in a separate file, and include it on all your web pages.

Activate SSI Apache

 

Steps to enable Server Side Includes (SSI) in Apache

 

1. Open .htaccess or server configuration file

 

Initially, enable mod_rewrite (.htaccess) in your Apache web server, Open .htaccess file, that is located at /var/www/html/.htaccess

 
$ sudo vi /var/www/html/.htaccess
 

Alternatively, if you have access to the Apache configuration file, you can open it

$ sudo vi /etc/apache2/httpd.conf
 

2. Enable Server Side Includes

 

Add the following line to .htaccess:

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

If you have opened the server configuration file then add the following lines:

Options +Includes 
AddType text/html .html 
AddOutputFilter INCLUDES .html
 

The above lines will enable server side includes and instructs apache to look for SSI in .html files. You can enable server side includes for other file types by adding the below lines.

AddType text/html .shtml 
AddHandler server-parsed .shtml
 

3. Restart Apache web server

 

Next restart the Apache web server to apply changes:

# service httpd restart
OR 
# systemctl restart httpd
OR
# sudo service apache2 restart
 

4. Verify Server Side Includes

 

Finally, add the below line to your PHP web page” /index.php” to display today’s date on it.

<!--#echo var="DATE_LOCAL" -->
 

Open the browser and go to http://domainname_or_ip/index.php. You will get today’s date displayed at the same location where you have added the above code.

 

Example SSI  Directives

 

Now that you have SSI enabled on your Apache web server, further you can use some examples SSI directives in action.

Few syntaxes for SSI directives is as shown below:

    <!–#element attribute=value attribute=value … –>

To include a header on web pages:

    <!–#include virtual=”/header.html” –>

To include today’s date on a web page:

    <!–#echo var=”DATE_LOCAL” –>

Display the modification date of a web page:

    Document was last modified on <!–#flastmod file=”index.html” –>

 

Conclusion

Apache allows you to configure server-side includes (SSI) to add dynamic web content, HTML code, and it reuses them more efficiently.

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.