Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking to rewrite an incoming url request on TomCat with the Tuckey rewriter:

<rule>
<from>/OutputFile?sourceArticleId=([0-9]+)</from>
<to>/app/clipping/get/$1</to>
</rule>

the "?" question mark fails the regexp pattern matching. How can I properly escape it or what is the correct solution for this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I' m not too familiar with reg exp in urlrewrite but you can try:

<from>/OutputFile\?sourceArticleId=([0-9]+)</from>

In many languages, the escaping character is the \

Update:

According to the doc, by default, the query string is not included in the <from> element. So you can try with the use-query-string set in the urlrewrite

Also make sure that the default-match-type in the <urlrewrite> is set to regex (I use the Spring MVC template from STS and it is set to wildcard by default

<urlrewrite use-query-string="true">
<rule match-type="regex">
    <from>/OutputFile\?sourceArticleId=([0-9]+)</from>
    <to>/app/clipping/get/$1</to>
</rule>
...
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.