IIS URL 重写规则 - 子目录的默认文档
我想创建 URL 重写规则,为我的虚拟文件夹设置默认文档。例如。像这样的
www.domain.com/en/ -> www.domain.com/en/index.aspx
www.domain.com/hr/ -> www.domain.com/hr/index.aspx
www.domain.com/de/ -> www.domain.com/de/index.aspx
目录 en、hr、de 并不真正存在于 Web 服务器上,它们只是本地 http 模块使用的站点中使用的语言标记,该模块将使用查询参数重写路径。
快速解决方案是为每种语言定义规则,如下所示:
<rewrite>
<rewriteMaps>
<rewriteMap name="Langs">
<add key="/en" value="/en/index.aspx" />
<add key="/hr" value="/hr/index.aspx" />
<add key="/de" value="/de/index.aspx" />
</rewriteMap>
</rewriteMaps>
<rules>
但我真的很喜欢不需要更改 web.config 并为特定站点上使用的每种语言添加重写规则的解决方案。
谢谢 !
I would like create URL rewrite rule that will set default document for my virtual folders. eg. someting like this
www.domain.com/en/ -> www.domain.com/en/index.aspx
www.domain.com/hr/ -> www.domain.com/hr/index.aspx
www.domain.com/de/ -> www.domain.com/de/index.aspx
directories en, hr, de doesn't really exists on web server they are just markers for languange used in site used by home grown http module that will rewrite path with query params.
Quick solution was define rule for every single lang, something like this :
<rewrite>
<rewriteMaps>
<rewriteMap name="Langs">
<add key="/en" value="/en/index.aspx" />
<add key="/hr" value="/hr/index.aspx" />
<add key="/de" value="/de/index.aspx" />
</rewriteMap>
</rewriteMaps>
<rules>
But I would really like solution that would not require changes in web.config and adding rewrite rule for every languange used on particular site.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该允许您从请求中捕获语言标记并将其重写到您的自定义 http 处理程序。
That should allow you to capture the language tag from the request and rewrite it to your custom http handler.