SSI Includes

Published January 01, 2007

How to embed CGI scripts in HTML files

In order to embed CGI scripts, first find if your web hosting company supports Server Side Include (SSI). Call or email your tech support to find this. [If you're hosting on Bluehost, yes they support SSI]

  • Create a new .htaccess file or open the existing .htaccess file in the same directory where you want your SSI includes to exist
  • Add these two lines
AddType text/html .html
AddHandler server-parsed .html
  • You may want to add this line if you want to execute Perl scripts ending in .pl or .cgi
    AddHandler cgi-script pl cgi

Testing the SSI include

Lets create a file called ssi.html that embeds a Perl script This Perl script outputs the current date and time when executed.

  • Create ssi.html with these contents:

SSI Test

  • Create in the same directory with these contents:
#!/usr/bin/perl -w

print `date`;
  • If your CGI script is in another directory, you can call it from the HTML page using the include virtual directive

SSI Test

  • Make the script executable with by chmodding with +x or FTP client or whatever CP you use to access your files


Check out the working demo here.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: January 01, 2007.     This post was originally written on January 02, 2007.