Search code examples
asp.netumbraco7

Url rewrite return 404 error when spaces replaced with + in umbraco


I need to rewrite a url in umbraco. It is currently working if i leave the spaces in. However i want to remove the spaces and replace them with a + for more user friendly urls without a %20.

So this is working.

/For-Sale/6_24-Hunter Street-KELVIN GROVE-4059

But this does not. And umbraco just tells me that the page cannot be found. 404 error.

/For-Sale/6_24-Hunter+Street-KELVIN+GROVE-4059

This is the umbraco url rewrite rule that i am using.

<add name="SaleRule"
     virtualUrl="^~/For-Sale/(.*)"
     destinationUrl="~/Result/Item?type=For-Sale&amp;address=$1"
     rewriteUrlParameter="ExcludeFromClientQueryString"
     ignoreCase="true" />

Any idea on what i am doing wrong?


Solution

  • For those that experience this issue here is how i resolved it.

    I found the answer in the following post - Is Enabling Double Escaping Dangerous?

    To allow the + symbol in the url i needed to set the following in the web.config.

    <system.webServer>
        <security>
            <requestFiltering allowDoubleEscaping="true"/>
        </security>
    </system.webServer>
    

    The Url rewriting rules i had in Umbraco where correct.