Value of DOCUMENT_URI inconsistent in nested SSI, if vs echo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings Apache gurus!


My attempted use case is to use Apache server side includes to adjust the styling of a NavBar, highlighting the active page, but it’s not working. The reason why is that in a nested SHTML file, it appears the the variable DOCUMENT_URI, when referenced by an <!--#echo is the document requested by the user (which, I think, is how it should be) but when referenced by an <!--#if _expression_, it is the nested document (which, I think, is incorrect) but I have no idea why.


Rather than dump all the code here for my home page and nav bar, I wrote a quick proof of concept that seems to demonstrate my issue focusing directly on the SSI.


Here is my baseline to make sure my basic code and expressions are correct.


File: direct.shtml

<!DOCTYPE HTML>

<html lang="en">

<head>

<meta charset="UTF-8">

</head>

<body>

<p>

Per an SSI echo, The name of this document is: <!--#echo var="DOCUMENT_NAME"-->

<br>

<!--#if expr="%{DOCUMENT_URI} == '/direct.shtml'" -->

Per an SSI if test, this file is called /direct.shtml

<!--#else -->

Per an SSI if test, this file is NOT called /direct.shtml

<!--#endif -->

</p>

</body>

</html>


Produces this output:

Per an SSI echo, The name of this document is: direct.shtml
Per an SSI if test, this file is called /direct.shtml


Which is exactly as I expect.


Now, here is file: indirect.shtml

<!DOCTYPE HTML>

<html lang="en">

<head>

<meta charset="UTF-8">

</head>

<body>

<p>

Per an SSI echo in the main file, the name of this document is:

<!--#echo var="DOCUMENT_NAME"-->

<br>

Now we're going to include nested.shtml.

<hr>

<!--#include virtual="nested.shtml" -->

</p>

</body>

</html>


And the referenced file: nested.shtml

<br>Now that we're in nested.shtml, per an SSI echo, the name of this document is:

<!--#echo var="DOCUMENT_NAME"-->

<br>

<!--#if expr="%{DOCUMENT_URI} == '/indirect.shtml'" -->

Per an SSI if, this file is called /indirect.shtml<br>

<!--#else -->

Per an SSI if, this file is NOT called /indirect.shtml<br>

<!--#endif -->

<!--#if expr="%{DOCUMENT_URI} == '/nested.shtml'" -->

Per a second SSI if, this file is called /nested.shtml<br>

<!--#else -->

Per a second SSI if, this file is NOT called /nested.shtml<br>

<!--#endif -->


Which produces this output:


Per an SSI echo in the main file, the name of this document is: indirect.shtml

Now we're going to include nested.shtml.

--------------------

Now that we're in nested.shtml, per an SSI echo, the name of this document is: indirect.shtml

Per an SSI if, this file is NOT called /indirect.shtml

Per a second SSI if, this file is called /nested.shtml


So having DOCUMENT_URI meaning one thing in an echo and something else in an if, but ONLY when in a nested SSI doc is the mystery I’m trying to solve. Have I done something wrong, are my assumptions incorrect, or is my Apache instance misbehaving?


Even if you don’t have an answer to WHY, would someone with Includes turned on in their environment be willing to try my code to see if you get the same output, just to see if this issue is unique to my environment? I’m using the 2.4.6-93.el7.centos build, at present, for testing.  I know it's WAY out of date, but I'm trying to stick with the managed package for my distro.  Either way, this doesn't seem like a terribly weird use case or an exotic function.


Any suggestions would be appreciated. I think I can fix this on the client side in _javascript_, but I’d like to know if I’ve done something wrong in my code as I rely on SSI in other places and if I can’t rely on it the way I’m using it I’d like to know.


Thanks,


Scott



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux