Forum Moderators: phranque

Message Too Old, No Replies

Using regexp subexpressions in SSI (mod_include)

errors in parsing regular expressions with parenthesis

         

dhatz

9:19 pm on May 16, 2004 (gmt 0)

10+ Year Member



Is anyone using Apache + SSI with subexpressions?

In my case, it bombs as soon as it encounters a parenthesis, e.g.

[Sun May 16 23:51:08 2004] [error] [client] Invalid expression "$DOCUMENT_NAME = /(fo¦sdsdf¦sdfsdf)/" in file /var/spool/htdocs/test/********xx

or like ([0-9]{4})([a-z]{1})([0-9]{2})$/

The file is a .shtml file and other SSI directives get parsed fine.

Basically I'm trying to create a navigation/location bar (much like the one on this site saying "Home / Forums Index / The Webmaster World / Apache Web Server / xxx" ) using SSI.

So I need to parse the URI into variables, before I can do that, and as I said, as soon as Apache encounters a parenthesis in the SSI regexp, it gives an error. Nothing works, not wildcard (.*) etc constructs etc.

On the other hand, using parenthesis in regexps in other the httpd.conf file, in the RewriteCondition directives, work fine.

According to the manual ( [httpd.apache.org...] ) I don't need anything else besides mod_include, do I?

dhatz

9:40 pm on May 16, 2004 (gmt 0)

10+ Year Member



Seems I have lost a couple of hours searching the net for nothing, as I was running Apache 1.3.x on that particular test machine and apparently regexp aren't supported until Apache 2.x

At least that's my explanation of the problem, as the suggested syntax of

Example
<!--#if expr="$QUERY_STRING = /^sid=([a-zA-Z0-9]+)/" -->
<!--#set var="session" value="$1" -->
<!--#endif -->

from [httpd.apache.org...]

gives an error on my setup :-((((

gergoe

10:55 am on May 17, 2004 (gmt 0)

10+ Year Member



I've never used SSI myself, but it sounds as if the parentheses were indeed not very well supported in 1.3. This can be due to the fact that in 1.3 you can't use back-references, so using parentheses in the regular expressions drops an error. Do you have the latest apache (1.3.29)?

Consider using different technique for including a header/footer, check out this thread, it might give you a good start:
[webmasterworld.com...]