What's wrong with this SSI - ssi

I'm having trouble with SSI. It seems like I don't get to work the most basic command:
<!--#if expr="${title}" -->
<!--#echo var="title" -->
<!--#endif -->
I think it's obvious what I want to do and I can't find what's wrong with this piece of code. However SSI says [an error occurred while processing this directive].
The echo without the if block works fine.

I've found the error:
Apache changed its syntax for SSI conditionals with Version 2.3 or something so now it has to look like that:
<!--#if expr='-n v("title")' -->
<!--#echo var="title" -->
<!--#endif -->

Related

Bootstrap group list shows text sprites at runtime

The code is listed below, using the bootstrap class class="list-group-item-text".
As the image here shows, the text seems to have a duplicate version just above it - looks almost like dotted lines.
`
<asp:Panel ID="pnlInstructions" runat="server" Visible="true">
<h4>Instructions:</h4>
<div class="form-inline col-lg-12" id="Instructions" style="padding-top:10px;padding-bottom:20px;padding-left:10px;">
<ol class="list-group-item-text" style="text-emphasis:filled;outline:none;">
<li>First, please use MyEd to get your extract file ready.</li>
<li>Then, fill in the following to Log in.</li>
</ol>
</div>
</asp:Panel>
`
I've researched the problem using the word "sprites", but that seems to have a different meaning than I expected, since I thought it meant "unwanted junk" in a display.
I'm not sure if this appears on all browsers.

Disable prettier for Tailwind classes

I really want to use Prettier but i get alot of extra lines of code because I also use Tailwind and Prettier formats every class on a new line.
Can I disable this?
Yes, as per prettier documentation, in an html file you can ignore the entire elemenent, all atributes or an specific attribute (which seems to be what you want)
<!-- prettier-ignore -->
<div class="x" >hello world</div >
<!-- prettier-ignore-attribute -->
<div
(mousedown)=" onStart ( ) "
(mouseup)=" onEnd ( ) "
></div>
<!-- prettier-ignore-attribute (mouseup) -->
<div
(mousedown)="onStart()"
(mouseup)=" onEnd ( ) "
></div>
Take a look at the documentation regarding ignoring parts of the code with prettier as the way and scope of ignoring may change depending on the file type.
Prettier Ignoring code documentation

switch case (or if else) to load a file with include in SSI and QUERY_STRING?

In PHP I can use switch case for using a simple function:
<?php
switch($_SERVER['QUERY_STRING']) {
case 'example1':
include 'example1.php';
break;
case 'example2':
include 'example2.php';
break;
case 'example3':
include 'example3.php';
break;
default:
include 'example1.php';
break;
}
?>
But how look it for SSI?
My not working example:
(Note: SSI is working with my Apache ;-) )
<!--#if expr="$QUERY_STRING = 'example1'" -->
<!--#include virtual="example1.html" -->
<!--#elif expr="$QUERY_STRING = 'example2'" -->
<!--#include virtual="example2.html" -->
<!--#elif expr="$QUERY_STRING = 'example3'" -->
<!--#include virtual="example3.html" -->
<!--#else -->
<!--#include virtual="example1.html" -->
<!--#endif -->
I get only an error message:
[an error occurred while processing this directive]
Thank you in advance :-)
OK, I found following for .htaccess and my example works...
SSILegacyExprParser on
But exist a valid code without to use this snippet?
Sources:
SSI IF Statement error in this forum
SSILegacyExprParser Directive on apache.org
Try using
<!--#if expr="v('QUERY_STRING') = '/example1'" -->
You shouldn't need the legacy parser turned on for that.

Server Side Includes syntax no longer works with Apache 2.4

I am using this syntax to check for the current document name with Server Side Includes (SSI):
<!--#if expr="$DOCUMENT_NAME = /index.shtml/" -->
<ul id="menu">
...
</ul>
<!--#endif -->
Unfortunately, this no longer works with Apache 2.4 (it used to work with version 2.2, though!).
What am I missing here? How can I get this to work?

How to get SSI variable REQUEST_URI without query parameters

I'm trying to get the pathname part of the REQUEST_URI, without the query parameters. I need to do this in raw SSI, without any PHP or anything.
If I do something like <!--#echo var="REQUEST_URI" -->, that will output the pathname plus the query parameters, so if the browser URL shows http://example.com/foo.html?bar, that would return /foo.html?bar. But I need to return only /foo.html. Is there a way to do that directly inside an echo statement?
Note: It needs to use the requested uri only. The actual file paths on the server are very different and I cannot display those.
I don't have a running nginx with SSI around, so i am just guessing here.
But maybe you can try to use a regular expression to extract what you want.
Maybe something like this:
<!--# if expr="$REQUEST_URI = /(.+)\?.*/" -->
<!--# echo var="1" -->
<!--# endif -->
I am not sure about the \ before the ?.
You could try to use the DOCUMENT_URI variable instead:
<!--#echo var="DOCUMENT_URI" -->
SCRIPT_NAME seems to work too:
<!--#echo var="SCRIPT_NAME" -->
This code works for me :
<!--#if expr="$REQUEST_URI = /([^?]+)\?.*/" -->
<!--#set var="URL_WITHOUT_QUERY_STRING" value="$1" -->
<!--#echo var='URL_WITHOUT_QUERY_STRING' -->
<!--#endif -->