I want to create an IIS rewrite rule that is based on the users browser language, but only for a specific set of languages.

Our website is available in English (en), French (fr), and Dutch (nl). I can create this rewrite rule:

<rule name="Redirect short url to long url: NEW SYNTAX 2017-11-01" stopProcessing="true">
    <match url="^([_0-9a-z-]+)$" />
        <add input="{HTTP_HOST}" pattern="mydomain\.be$" />
        <add input="{HTTP_ACCEPT_LANGUAGE}" pattern="^(en|fr|nl)?" />
    <action type="Redirect" url="https://www.myotherdomain.be/{C:1}/projects/{R:1}?type=shorturl" appendQueryString="false" redirectType="Found" />

This works fine when I configure my browser in one of the three specified languages (en/nl/fr). Eg URL http://mydomain.be/test will redirect to https://www.myotherdomain.be/nl/projects/test?type=shorturl (when my browser is configured in Dutch).

But when I configure my browser e.g. to "ru" then then the same url will redirect to https://www.myotherdomain.be//projects/test?type=shorturl

For any other languages I want to default the long URL to /en/ instead of // Is there any way to do this using IIS rewrite rules ?

Thanks in advance for any guidance!

1 Answer 1


For info: I solved my issue by adding a catch all rewrite rule, that redirects all request to a single .aspx page. In this .aspx page I can handle the proper redirect logic with C# in the backend code.

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.