我想创build一个基于用户浏览器语言的IIS重写规则,但仅限于一组特定的语言。
我们的网站有英文(en),法文(fr)和荷兰文(nl)。 我可以创build这个重写规则:
<rule name="Redirect short url to long url: NEW SYNTAX 2017-11-01" stopProcessing="true"> <match url="^([_0-9a-z-]+)$" /> <conditions> <add input="{HTTP_HOST}" pattern="mydomain\.be$" /> <add input="{HTTP_ACCEPT_LANGUAGE}" pattern="^(en|fr|nl)?" /> </conditions> <action type="Redirect" url="https://www.myotherdomain.be/{C:1}/projects/{R:1}?type=shorturl" appendQueryString="false" redirectType="Found" /> </rule>
当我用三种指定语言之一(en / nl / fr)configuration我的浏览器时,这工作正常。 如URL http://mydomain.be/test将redirect到https://www.myotherdomain.be/nl/projects/test?type=shorturl (当我的浏览器被configuration为荷兰语)。
但是,当我configuration我的浏览器,例如“ru”,那么相同的url将redirect到https://www.myotherdomain.be//projects/test?type=shorturl
对于任何其他语言,我想默认长URL到/ EN /而不是/ /有没有办法使用IIS重写规则做到这一点?
预先感谢您的任何指导!
有关信息:我通过添加catch全部重写规则来解决我的问题,该规则将所有请求redirect到一个.aspx页面。 在这个.aspx页面中,我可以在后端代码中用C#处理正确的redirect逻辑。