views:

355

answers:

3

I can't get server side includes to work. I simply want to include one html file into another and I just can't seem to get it working

Setup

The server is a another machine (not localhost) running Windows XP. I've got a slighly older version of the xampp stack which is running only Apache/2.2.11

Virtual directory (in httpd-vhosts.conf) is configured as

<Directory "c:\www\dev1">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

index.html contains

A Big Block of Text<br />
A Big Block of Text<br />

<!-- #include file="test.shtml" -->

A Big Block of Text<br />
A Big Block of Text<br />

test.shtml contains

This is another line

What I am getting

From the browser on my dev machine, www.dev.com/index.html shows

A Big Block of Text<br />
A Big Block of Text<br />
A Big Block of Text<br />
A Big Block of Text<br />
  • Page Source shows the !--- include which means the include file hasn't been processed
  • www.dev.com/test.shtml shows the file as indicated above so it is accessible.

Things I've tried

Read through a bunch of posts both here on stackoverflow and the internet and its helped "build" the basics for getting this to work (ie make sure Options has Includes enabled) but it still isn't working.

Changed

Options Indexes FollowSymLinks Includes ExecCGI to
Options Indexes FollowSymLinks Includes +Include ExecCGI to
Options Indexes FollowSymLinks +Includes ExecCGI

with an apache restart and it still doesn't work

Added .htaccess to the same directory as index.html and test.shtml

Options Indexes FollowSymLinks Includes ExecCGI 
AddType text/html .shtml
AddHandler server-parsed .shtml

and it still doesn't work.

Note. http.conf already has

AddType text/html .shtml
AddHandler server-parsed .shtml

enabled.

Yes, it is probably something real obvious but I've got a cold so if somebody could point me in the right direction, that would be greatly appreciated.

More Things I've Tried

Change include file to include virtual

I tried the suggestion by RichieHindle and it didn't seem to work and I've modified both my .htaccess and virtual directory configuration to include required combinations of AddType, AddHandler for both .html and .shtml ... still nothing

BIG NOTE: On the webserver, one can load a SSI checking webpage (via localhost in one of the xampp install directories) and it tells me that SSI includes are enabled and working, however, please note that my virtual directories are NOT in the xampp install directories; they are standalone under c:/www ... but I can't figure out how/why this makes a difference if I've configured the options outlined above in my virtual directory settings and/or .htaccess settings

+1  A: 

Do you need:

AddHandler server-parsed .html

?

Your HTML file is named index.html but you're only applying server-parsed to .shtml files.

RichieHindle
Okay if it is only parsing .Shtml files ... Copied index.html to index.shtml and loaded index.shtml in the browser ... nope, it didn't include the requested file.
BlueShepherd
and I tried adding AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddOutputFilter INCLUDES .html AddHandler server-parsed .shtml AddHandler server-parsed .htmlto my virtual directory configuration and still not including (loading either the .html file or .shtml file)
BlueShepherd
+2  A: 

Maybe try removing the space? From:

<!-- #include file="test.shtml" -->

to this:

<!--#include file="test.shtml" -->
Blair
Okay, I knew I was going to do at least one facepalm here. This (along with RichieHadle's pointer that I need to parse HTML files for includes) got it working. Thanks very much.
BlueShepherd
A: 

Your HTML file is named index.html but you're only applying server-parsed to .shtml files.

Ritchie, thanks a ton...your one liner has saved my day !:)

Satty