Forum Moderators: phranque

Message Too Old, No Replies

Setting up Apache to serve SSI's (beginner needs help)

Apache tutorial has left me baffled

         

udon333

9:42 pm on Jan 26, 2009 (gmt 0)

10+ Year Member



My aim is to use Server-Side Includes for adding common content like navigation, etc.

I have been reading the instructions at
[httpd.apache.org ],
but I can't get my include file to load into the test page. I tried with the .shtml file-extension on the test page as well as .html, but have had no joy - the page loads, but the include bit is missing.

In the config file I have checked that the following are in place:


LoadModule include_module modules/mod_include.so
#
#
<Directory "C:/sites/www/Mywebsite">
Options Indexes FollowSymLinks #this line was already there
Options Includes #I added this (and also tried just adding 'Includes' to the line above - didn't seem to make any difference)
AddType text/html .shtml #I added this
AddOutputFilter INCLUDES .shtml #I added this
</Directive>

In the test.html file I've added this line where the include needs to load, and changed it to test.shtml:


<!--#include virtual="/topnav.html" -->

I'm clearly doing something wrong, but I'm still new to Apache and server-speak, and I'm really stuck. Can anyone help please?

Many thanks!

Caterham

11:30 pm on Jan 26, 2009 (gmt 0)

10+ Year Member



That looks good, but you're overriding the other options defined, you you may want to add it to the 1st options directive (not problem related).

When you're looking at your HTML source send to your browser, do you see the include command as-is or something else (error message)? Did you restart apache after you made the changes?

udon333

9:40 am on Jan 27, 2009 (gmt 0)

10+ Year Member



Sorry, I had stupidly renamed the page back to test.html. Just changed that to .shtml again and it's working.

I'd like to keep the .html extension for all the pages that will have the includes, but the Apache tutorial warns against parsing all html files - yet I feel too out of my depth to use the XBitHack method described(the reference to the executable bit threw me!).
As I'm just adding includes which display flat html, should it be ok to parse all html files in this instance?

Caterham

11:00 am on Jan 27, 2009 (gmt 0)

10+ Year Member



As I'm just adding includes which display flat html, should it be ok to parse all html files in this instance?

That doesn't make a difference - html or script. The intention is not to parse files which don't have includes in them. The resource you're including doesn't matter in that case, because that's a phase prior inclusion or execution of a script. If the document is parsed but no includes are found, nothing will be included or executed.

You could use a more fine tuned setup, i.e. add AddOutputFilter only for certain filenames (e.g. starting with a) or RemoveOutputfilter for certain filenames. See the <files> and <filesmatch> sections.

udon333

2:37 pm on Jan 27, 2009 (gmt 0)

10+ Year Member



Thanks for clearing that up - So I'll avoid parsing all html!
I will look into fine-tuning the filters.
many thanks!