SSI (server side includes) is a great tool for any website - allowing you to update the navigation menus across all pages in a few lines of code, instead of having to change every page!
SSI is an easy way to manage pages in your site is by replacing chunks of repeating code, such as your navigation links, with SSI (server side include).
The blocks of code, usually HTML are stored in independent files in your server hosting account. These can be called into a document (web page), allowing for the centralization of commonly used code, such as for the header and
footer used in all pages on a website.
SSI is fairly obscure. Few people use it, because it normally requires shtml extensions. But if you are allowed to use an htaccess file, you can solve that problem.
Before you start, visit your ISP's FAQ pages and search for "htaccess." You need to check if your ISP allows you to use htaccess files.
DO NOT upload a new htaccess file unless you are very sure you can use it, it'll overwrite a hidden file and kill your website!
If these are not permitted, then you may still be able to use SSI but
need to make every link and every page on your site with the shtml extension.
If the htaccess file solution is not available to you - perhaps you can make more use of
PHP Includes.
The best way to explain SSI is to create a sample page that uses SSI. You have an index.html page and some subpages. Every page has its content. It also has universal elements that exist on all pages: a logo banner at the top, navigation bar on the side and a footer with more navigation items. Follow these easy steps:
Now go back to the index.html page. At the place where you have the NAVIGATION BAR, delete the HTML & replace it with the following:
<!--#include file="ssi-navbar.txt" -->
Go back to the index.html page. At the place where you have the BANNER, delete the HTML & replace it with the following:
<!--#include file="ssi-banner.html" -->
Next, go back to the index.html page a third time. At the place where you have the FOOTER, delete the HTML & replace it with the following:
<!--#include file="ssi-footer.html" -->
Finally, rename the index.html page to index.shtml & load it on your server, so that the html page
& your 3 new txt files are all in the same directory in your hosting account.
These are SSI links. When a visitor's browser opens your website, the server will fetch the navbar.txt, banner.txt and footer.txt files, insert them into the HTML & send the page to your visitor. The visitor will see your page, as it should be!
As previously stated. SSI has a bit of a problem - all files must be renamed filename.shtml, plus all of your links must be renamed to end with the extension shtml. This can be a major problem for people to remember and use.
But there's a solution to this. You can use .htaccess to redirect the files. This file is named ".htaccess" (which is
pronounced dot-h-t-access). It has no extension.
The htaccess file lets you use .shtml extensions & it reinterprets those as if they were .html extensions. Basically, you say .shtml, but the computer thinks you said .html, so you avoid the file naming problems.
Now, you can't actually write a .htaccess file on a Windows (or
Mac) machine, because these machines won't let you create a file with
an extension but no name.
This is how to do this.
AddType text/html .shtml
AddHandler server-parsed .shtml .html
Save the file as htaccess.txt, set your file transfer to ASCII (not binary,) and upload it to your website. Place it in the same folder as your website's index.html file. Now rename the file on your server. Change it to .htaccess (note the period at the beginning of the name) and save.
After you've uploaded and renamed the htaccess file, use your browser to visit your site. If you can see your website, it's okay.
If nothing shows up, well, you've got to call your ISPs tech support and explain that you uploaded an htaccess file and ask them to restore the site.
Webcritique.org is a Priday Design Studio service.
Priday Design Studio is based in Birmingham, UK and provides web design and site maintenance services for SME & club/associations throughout the UK. Domain names and hosting facilities are provided by associated site, PDS-Hosting Solutions, enabling us to provide you with a complete service.