luceetuckey-urlrewrite-filter

How to add escape characters in URLRewrite


I would like to add the following rule in my urlrewrite.xml (Lucee server):

<from>^([a-zA-Z0-9\/\-\%\+:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$</from>
<to type="passthrough">/index.cfm?furl=$1</to>

but unfortunately i receive an error regarding < character. For your better assistance, i attach the following image:

enter image description here

Any idea that could help me?

Regards


Solution

  • You're putting invalid characters in your XML value.

    This is what it should be:

    <from>^([a-zA-Z0-9\/\-\%\+:\[\]\{\}\|\;\&lt;\&gt;\?\,\*\!\@\#\$\ \(\)\^_`~]*)$</from>
    

    These characters need to be escaped in XML:

    &
    '
    "
    <
    >
    

    See: https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML