homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

Setting up SSI to inject text and html code

 6:40 pm on Feb 5, 2001 (gmt 0)

I need some step-by-step on this, feel free to point me to some tutorials if you know of any.

I have a dedicated unix server hosting approx. 50 domains. These domains have content along a general theme. There are roughly 10,000 pages ending in .htm, .html, and .shtml. Due to legacy issues with the SE's, I cannot change the extension of many of the existing .htm and .html files. Nor do I want to use .htaccess to globally declare these to be SSI enabled.

For over a year now, I've been using external .js files and absolute calls to inject navigation globally across any/all pages, regardless of the extension or the domain or subdirectory where the file is located.

I now want to inject ads and navigation using SSI and abandon external js, browser sniffing, etc.
First, the simplest question (I hope)... on files that are .shtml -
- How do I construct the text to be written into the files, or are they just .txt files?
- Where do I place these files, in the cgi-bin, or just set up a holding directory somewhere on the machine?
- How do I constuct the SSI call?
Now on to what, for me, seems the more complex issue -enabling the old .htm and .html files so that the SSI call will work.

Can I use .htaccess at the subdirectory level to declare every .htm file located within that subdirectory to be SSI-enabled? OR, do I have to do it for the whole domain, or even the whole machine?



 7:00 pm on Feb 5, 2001 (gmt 0)

To setup .html and .htm files to be treated as .shtml, I added:

AddType text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm

to my .htaccess file. Not sure how to do it/if it's possible for subdirectory level.

I have also seen the following, but haven't used it:
AddHandler server-parsed .html .htm .shtml

To make the SSI call, just put:
<!--#include file="file.html" -->

where you want the include to go. The files can be .txt or .html and are just plain code, nothing special needed. This is for the include to be in the same dir as the calling page.

To use include files stored elsewhere, use:
<!--#include virtual="/path/to/your/file.html" -->

Be sure to leave a space after the last " before the "-->"



 7:26 pm on Feb 5, 2001 (gmt 0)

OK, here's an alternative to .htaccess via telnet chmod commands offered by my server guys

To enable every .htm and/or .html file in a directory AND in subdirectories below it:
chmod -R u+x *.htm*

To enable every .htm and/or .html file in only the current directory or subdirectory:
chmod u+x *.htm*

To specify individual file(s) in only the current directory or subdirectory:
chmod u+x filename01.htm filename02.html filename03.htm

(I think I listed this correctly, let me know if there are any errors.)

The server guys were also outlining a way to set up a single master listing (in a .txt file) of enabled individual files in the root ...they were jabbering something about backticks and full paths. I'll explore that later perhaps.

Edited by: rcjordan


 8:32 pm on Feb 5, 2001 (gmt 0)

>set up a single master listing (in a .txt file) of enabled individual files

To keep cpu load down by listing the exact file, and to make this more easily manageable from a single central location, I'm going to try the above. The server guys are setting it up. The only negative is that I'll need to have the server run an update every time I add a file. I could have them set it up in the cron, but once I get this list built I don't think there will be many additions.


 9:16 pm on Apr 20, 2001 (gmt 0)

I would like to accomplish this same thing using Win2k and IIS.

I'm setting up a free hosting site. Basically I need to add a header and footer on every .htm .html page that is created in their directory.

Can I accomplish this with Win2k IIS 5.0 ?

Thanks in advance,


 9:58 pm on Apr 20, 2001 (gmt 0)

Bob, that approach you are using via command line will only works on servers that have XBitHack turned on. It is cool that they provide that option because it will allow you to select which pages you want the server to parse -- so the server won't be as stressed out.

On NT you won't have to worry about the permissions, but changing the extension association is an 'administrative' job. I'm sure Xoc could do a good outline for you.


 3:56 am on Apr 21, 2001 (gmt 0)


Welcome to WMW. To allow scripts to run on IIS for .htm pages or any other extensions:

To configure IIS to process .htm files allowing scripts:

1 Start up Internet Service Manager
2 Select the web site you want to do the processing on
3 Right click on it and select Properties
4 Select Home Directory
5 If necessary, create an application
6 Press Configuration
7 Select .asp and press Edit
8 Copy down the information in the dialog
9 Press Cancel
10 Press Add
11 Use the file extension .htm, use all the other information that you copied down in step 8
12 Press OK to all the dialogs
13 Restart IIS for good measure

If you don't have access to the web server, you will have to get friendly with your ISP to make this change.


 4:09 am on Apr 21, 2001 (gmt 0)

Xoc, will that work for regular server side includes?
<!--#exec cgi="/cgi-bin/SCRIPT.cgi" --> ...


 12:21 pm on Apr 22, 2001 (gmt 0)

Yes, SSI will work after you do that. However the only two keywords that ASP SSIs understand (as far as I know) are #include or #virtual, not #exec.


 3:20 pm on Apr 22, 2001 (gmt 0)

Thanks for the info.


 5:01 am on Apr 23, 2001 (gmt 0)

I guess the real quesion is how do I add a header and footer to all htm, html pages automatically?

I'm planning on running a free hosting website. Webmasters can upload htm/html pages to the server. There is no way I can manually had a header and footer using the "include" command.

Any idea on how to add the include to all htm pages that are served within a directory?


 5:01 pm on Apr 23, 2001 (gmt 0)

I *think* this could be done by:

1. Using .htaccess to direct all hits to the directory to the same "shell page"

2. The shell page could contain the header and 2 include directives

3. The first include runs a script to identify/display the requested page.

4. The second include displays the footer


 6:54 pm on Apr 23, 2001 (gmt 0)

Thanks Dave but I'm doing all this on NT :(


 1:25 am on Apr 24, 2001 (gmt 0)

doulos, understand that I'm coming from a place of ignorance on this subject, so indulge me on this answer.

I would personally do a search on free NT hosting, take space at a couple, try to garner a few clues as to how they're doing it, and probably ask tech support a few "dumb questions" (I learn a lot that way);)

I assume you want to include ad banners for yourself, and include a text link to your main site for the free hosting. I've seen a couple of free sites use an iframe for their ads - not a clue how they implement this, though.

I do happen to know that webjump.com offers free NT hosting - they use a top frame, and all of their sites display with their frame on top. You might want to check out how they're doing it. Also, there are some free web space providers who will work cooperative ventures with webmasters who want to offer free space, and the sites run on their servers.


 2:32 am on Apr 24, 2001 (gmt 0)

Hey doulos, I'm confident NT has some mechanism for redirecting visitors, on Apache/*nix it's typically the .htaccess file. So when you discover what it is on NT servers, you have a complete solution.

No offense, but I learned a good deal more by rolling up my sleeves and digging in, doing the research and studing, then by asking questions and expecting others to solve all of my problems. Perhaps it's time to go learn a bit more about NT? :)

Marcia offered some good advice, ask the people who operate an NT server, they are most famialiar with what it can do...


 1:24 pm on Apr 24, 2001 (gmt 0)

There is a way in the IIS configuration dialogs to specify for any given file or directory that you want the file to redirect somewhere else.

1. Select the directory, right click on it, then select "properties".
2. In the dialog, select the "Home Directory" tab.
3. Click on "A redirection to a URL"

Then read the help on how you can configure the URL...you have a fair amount of flexibility on how you do it.


 9:19 am on Jun 11, 2001 (gmt 0)

I want to correct something that I said above...#exec will work on an IIS machine, but it takes some preparation.

First, it only works in .htm pages, not .asp pages.

Secondly, you have to change a registry setting in IIS 5.0 before it works. In IIS 4.0, you the default is enabled.

The key is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ SSIEnableCmdDirective = 1

See http://www.microsoft.com/ windows2000/en/server/iis/ default.asp?url=/WINDOWS2000/en/server/iis/htm/core/iiregwww.htm [microsoft.com] for more details.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved