我通过以下SSI命令得到了我需要的url部分:
<!--#set var="uriVariable" value="$DOCUMENT_URI" -->
现在我应该提取此字符串的第一部分,如下例所示:
uriVariable = "/questions/ask.html"
-- operation on the uriVariable --
parsedURI = "/questions/"
问题通过以下代码解决:
<!--#if expr="v('DOCUMENT_URI') =~ /([a-z]{2}_[a-z0-9]{2,5})/ && $1 =~ /([a-z]{2}_[a-z0-9]{2,5})/"-->
<!--#set var="contextPath" value="$0" -->
<!--#endif -->
<!--#echo var="contextPath" -->