logo
backtop

Technology Forum, Apache Web Server Sub-Category, Server Side Includes stopped working Thread

Rag
23rd November 2007
I've actually solved this problem, but more by luck than judgment so I thought I'd include the details here in case anyone has the same problems and tries to search for the answer.

I currently have two machines - one old Windows 2000 professional (that this website is on) and one Windows XP Home Edition SP2 (that I use as my home PC and as a development box).

The localhost on the development box (XP) stopped working for server side includes (SSI). Seemingly for no apparent reason, it seemed to just hang when you requested a .shtml page (.shtml pages are setup as being those that need to process includes). The browser displayed part of the page sometimes, but left it “waiting for a response.” I even left it for 4 hours to see if it would actually load the page, but it didn't.

A couple of things made this really weird - first, this was working fine before and I have no idea why it stopped working; second, the configuration was the same as on the Windows 2000 machine that was working as expected; and third, includes were being processed fine through PHP (so PHP pages loaded correctly and if you converted a .shtml to .php it worked fine).
Rag
23rd November 2007
I still don't know why it stopped working, but I can tell you how to fix it if it happens to you (and the same would apply if you had a new install and SSI were not working properly).

First, check the basics that Apache is setup to process SSIs.
  • In your Apache configuration file httpd.conf make sure that the options are set to allow includes for the directory. There should be an entry in the section for options - mine reads “Options Includes Indexes FollowSymLinks MultiViews.” The important bit is the word “Includes” as this tells Apache that it can process includes for files in this directory. Note that you should not have a “+” before the word Includes.
  • You should also probably add “index.shtml” to the “DirectoryIndex” line.
Now, from everything I've read, you should just uncomment out the lines “#AddType text/html .shtml” and “#AddOutputFilter INCLUDES .shtml” by removing the “#” symbol. It seems, however, that you need to do a little more than this. These lines seem to be used to create a mime type for the files processed through the include. It appears that you need to also create a handler for these files in order for the file to be handled. This is fairly straight forward as you just add the line “AddHandler server-parsed .shtml” and you have a handler. After making this entry I noticed that some of the pages started working. OK - progress. So I randomly wondered what would happen if I created mime types and handlers for the files that were being processed through the includes. I started with .inc files (these are just plain html files that I have in a library for repeatable objects - like the page header, menu and page footer).

It worked! There were still other pages that were hanging, so I went ahead and created entries for all of the file types that I'm using (except PHP as these are processed by PHP) and it works fine now. The entries I have are as follows:

    AddType text/javascript .js
    AddHandler server-parsed .js
    AddType image/jpeg .jpg
    AddHandler server-parsed .jpg
    AddType image/gif .gif
    AddHandler server-parsed .gif
    AddType image/png .png
    AddHandler server-parsed .png
    AddType text/html .shtml .html .inc
    AddHandler server-parsed .shtml .html .inc
    AddOutputFilter INCLUDES .shtml