I'm using Apache 2.4 and Server Side Includes.
When I use this:
<!--#echo var="DOCUMENT_URI" -->
It returns: /foo/bar/file.html
I want to capture the parts of the URI, i.e.:
<!--#if expr='v("DOCUMENT_URI") =~ [\/\\](.+)[\/\\](.+)[\/\\](.+)[.]'-->
<!--#set var='URI_PART1' value='$1' -->
<!--#set var='URI_PART2' value='$2' -->
<!--#set var='URI_PART3' value='$3' -->
<!--#else -->
<!--#endif -->
I have tried a lot of variations, but cannot get Apache to recognise the regex at all, in any way. I was expecting "foo", "bar" and "file" to be recorded but instead receive the error [an error occurred while processing this directive].
I know the syntax has changed since Apache 2.4 and the above is what I've come up with based on my understanding of the new syntax..
Any help appreciated!
This is reported as a bug, but un-resolved: https://bz.apache.org/bugzilla/show_bug.cgi?id=57448
There is a workaround as demonstrated in comment 8, to extract single values via $0, by adding this fragment:
&& $1 =~ /(.*)
which maps $1 to $0 as $0 is properly exported.
So you would have to extract your parts one at a time.
The other workaround is to enable and work with SSILegacyExprParser