Server Side Includes (SSI)
Server Side Includes are simple code added to HTML or other types of web pages to tell the server grab another HTML (or other web page type) and place it where the code is. Ok, I know that’s confusing so I’ll try to explain it.
Here is the code: <!--#include virtual="/includePage.html" -->
You just switch “includePage.html” with your web page your good to go. No code needs to be in your head tags or anything. Your server (or your hosting companies server) will recognize this code and know to replace it with the path you gave.
With that said, here are a couple things to remember about this. A lot of people state that you can only do this with ASP or shtml pages, but I got it to work with normal HTML pages, you may however need to change your permissions on your webpage to 755. I know that 777 allow the “world” to write to your pages, but 755 doesn’t, but isn’t the most secure permission.*
Another important thing to remember is the include page that your pointing to (in this example it’s the includePage.html) should have no <HTML> <HEAD> <BODY> tags since you already have that in your main page. Just your content like table, image, copy etc should be in the include page.
Why are includes a good thing to use?
SSI’s are great for right columns or information that is redundant on many pages. Therefore you now only need to update one page when using an include instead of having to update every page.
Dreamweaver support:
In Dreamweaver you can easily insert includes on your web page by selecting INSERT > SERVER-SIDE INCLUDE. It will then prompt you to find the file you want to insert where your curser currently is. Give it a try!
Enabling SSI in a Directory
If you’re concerned about the performance loss that occurs by enabling SSI across a large website, you can enable it on only a single directory by creating a .htaccess file in that directory with these lines:
AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
This will also allow you to enable SSI throughout a site if you put this .htaccess file in your root directory — useful if your server definitely supports SSI but your hosts won’t enable it in the config files.
sourcetip: Windows users may have trouble creating a file starting with a dot, as .htaccess files require. To get around this, upload your file as normal text and rename it on the server.
*Most FTP clients have the ability to change permissions to files and directories
|