I’ve got a 10 year old Apache server (FreeBSD) where the following works:
File1.htm
<!-- #set var="myDir" value="/dir" -->
File2.htm
<!-- #include virtual="File1.htm" --> //sets myDir
<!-- #include virtual="${myDir}/File3.htm" --> //loads /dir/File3.htm
File3.htm
<!-- #include virtual="${myDir}/File4.htm --> //loads /dir/File4.htm
On a very recent Suse Linux with the latest Apache, it seems that
myDir is not defined in File3.htm, and thus it can’t find and load File4.
So File2 can load File3, but File3 fails to load File4. It works in the 10-year old Apache on FreeBSD, but not on a recent Apache on Linux….
Any ideas?
EDIT For completeness’ sake, this is basically the config file:
DocumentRoot "/srv/www/htdocs"
<Directory "/srv/www/htdocs">
Options Includes
AddType text/html .htm
AddOutputFilter INCLUDES .htm
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I’ve made a test on my Ubuntu 11.04 system (with Apache 2.2.17), and I’ve had no problems at all.
Here are the files I’ve used:
File1.htm (located in the same folder of File2.htm)
File2.htm (located in the same folder of File1.htm)
File3.htm (located in the “ssi” subfolder)
File4.htm (located in the “ssi” subfolder)
This is my “.htaccess” file:
And here is the output that I get by requesting the page “File2.htm” in my browser:
Start File2
Start File1
/test/stackoverflow/ssi
End File1
/test/stackoverflow/ssi
Start File3
/test/stackoverflow/ssi
Start File4
/test/stackoverflow/ssi
Thursday, 30-Aug-2012 21:45:57 CEST
End File4
End File3
End File2
You should also:
By the way, I suppose that the missing closing quote in your “File3.htm” is only a typo.