<< Courier IMAP Fixing Script | Journals | Transplating Disks >>
Introduction
The easiest way to include html files inside another html file is to use Server Side Includes. It has a simple syntax of:
<!--#include virtual="somefiletoinclude.html" -->
This will only work for hosted website which allows script parsing. It will probably not work for free websites.
The challenge however is that most website will only parse shtml files, this means that if you include the above line in index.html, it will probably not work. However, renaming index.html to index.shtml would more likely tell the Apache server to parse and include the file.
Options
- You can rename all html files to shtml
- The problem with this is that any references from within your document that is looking for the html file will break. So you need to edit your files when you do this.
- Change the httpd.conf to tell Apache to parse all html files. The default is only to parse shtml
- You have 2 issues to deal with here. You need to be the system administrator to change httpd.conf.
- If you are the system administrator, you need to consider the overhead of parsing all html in your site whether they have a script or not. If you have a popular site - this may be a factor, but if not - the overhead may not be that great.
- Override the httpd.conf with the .htaccess directives
- This is probably the best or only alternative for hosted sites. Add the following directives to the .htaccess in directories that needs html or htm parsing. This way, only pages in these directories will have the parsing overhead.
AddType text/x-server-parsed-html .html .htm
Additional Notes
<!--#include virtual="somefiletoinclude.html" -->
vs
<!--#include file="somefiletoinclude.html" -->
The include virtual will allow you to specify URL i.e. http://somesite.com/somefile.html whereas the file will be of locally referenced files only.
Rommel Pascual October 16, 2007, at 02:14 PM