配置重定向 asp.net/iis7
我有一个网站,当用户输入 http://example.com 或 http://www.example.com。
我需要将服务器或应用程序配置为在访问 example.com 时永久重定向到 www.example.com。
非常重要的是保留路径,因此如果 example.com/path/page.aspx?p=1,则应重定向到 www.example.com/path/page.aspx?p=1。
谢谢!
I have a website that opens when the user enters either http://example.com or http://www.example.com.
I need to configure the server or the app to redirect with a permanent redirect to www.example.com when example.com is accessed.
What is very important is that the path is preserved, so if example.com/path/page.aspx?p=1, the redirect should be done to www.example.com/path/page.aspx?p=1.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 URL 重写,您可以通过在 web.config 中添加配置来完成此操作。您还需要在 IIS 中安装此模块。这是一个示例,未经过充分测试:
Using the URL Rewrite you can do this by adding a configuration in you web.config. You need to install this module in your IIS as well. Here is an example, not fully tested:
URL 重写模块 应该完全满足您的需要。
The URL Rewrite module should do exactly what you need.