【问题标题】:URL Rewrite multilingual site for default language in MVC 5URL 重写 MVC 5 中默认语言的多语言站点
【发布时间】:2021-09-24 22:41:03
【问题描述】:

我在 MVC 5 中有一个多语言网站。我已经使用属性路由实现了对 SEO 友好的 URL。 以下是示例网址:

http://mycompany.com/en
http://mycompany.com/en/about_us
http://mycompany.com/en/product/type/item

http://mycompany.com/fr
http://mycompany.com/fr/about_us
http://mycompany.com/fr/product/type/item

现在,我需要删除默认语言英语的语言代码 (en)。

如何使用 IIS URL 重写工具实现这一点? 任何替代解决方案也可以。

【问题讨论】:

    标签: iis url-rewriting asp.net-mvc-5


    【解决方案1】:

    你可以试试这个规则。当用户输入网址时,它会被重定向到无语言的网址并显示在浏览器中。

    <rule name="rule2" enabled="true" stopProcessing="true">
                    <match url="en(.*)" />
                    <action type="Redirect" url="{R:1}" />
    </rule>
    

    【讨论】:

    • 感谢布鲁斯,它成功了,虽然现在我必须编写那些新路线,这很明显。
    猜你喜欢
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 2014-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多