RE: Include a text file

by Chuck Evans <Chucke(at)captura.com>

 Date:  Wed, 24 May 2000 09:59:29 -0700
 To:  "'Suresh K Volam'" <education(at)volam.com>,
"'HWG Techniques'" <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
<shortanswer>Yes. Use Server Side Includes (SSI).</shortanswer>

<longanswer>

You can include any text you want into an html file by using what is called
a Server Side Include (SSI). The basic statement is:

<!--#include virtual="/includes/copyright.txt"-->

The file you are including does not have to have a .txt extension. It can be
.html, .inc, or whatever you like it to be.

However, SSI's only work if 1) the web server you are using supports SSI
(most, like Apache and IIS, do) and 2) your original html file has the
proper extension so the web server knows to look into it for SSI statements.
In Apache, the default is usually .shtml, and in IIS, the default is usually
.stm.

With that information, you should be able to experiment on your own server
to see what works.

But what if your site is already existing, uses .html extensions, and you
don't feel like changing the extensions on all of your pages? You can still
use SSI, but the answer gets more complicated. So complicated that I don't
have time to write them all out here. But if you use Apache and have access
to your http.conf file, the comments in there can point the way to adding
whatever extension you like as an SSI extension. You can also look to
http://www.apache.org for help. 

For IIS, you'll need to look into the MS knowledgebase at:

http://support.microsoft.com/support/kb/articles/Q161/5/62.ASP

</longanswer>

I hope this helps.

---------------------------------------------------------
Chuck Evans
Web Marketing Manager
Captura Software, Inc.
(425) 424-1155
chucke(at)captura.com
www.captura.com

-----Original Message-----
From: Suresh K Volam [mailto:education(at)volam.com]

Can we include a text file in a html document ?  If so, how do we do that ?
I have a part of code that is repeated on many pages.  If I can save the
common code as a text file and 'include' it wherever necessary, then it
would help me a lot.  TIA.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.