7

I have following rewrite rule in web.config:

<rewrite>
  <rules>
    <rule name="Search" stopProcessing="true">
      <match url="^search/(.+)$" />
      <action type="Redirect" url="?q={R:1}" />
    </rule>
  </rules>
</rewrite>

It works fine both on IIS Express 8.0 and IIS 7.5 on Azure Websites for urls like /search/test (only ascii characters) - redirects to /?q=test. But for urls with unicode characters (/search/тест or /search/%D1%82%D0%B5%D1%81%D1%82) on IIS 7.5 on Azure Websites redirects to /?q=теÑÑ‚ (or /?q=%C3%91%E2%80%9A%C3%90%C2%B5%C3%91%C2%81%C3%91%E2%80%9A) instead of /?q=%D1%82%D0%B5%D1%81%D1%82. It works correctly on IIS Express 8.0.

1 Answer 1

12

You should use the internal {UrlEncode:{}} function to properly encode the characters that are invalid in the URL (e.g. UTF-8 characters). So replace the URL part with: url="?q={UrlEncode:{R:1}}".

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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