【问题标题】:URL Rewrite for subdomains in ASP.NetASP.Net 中子域的 URL 重写
【发布时间】:2012-07-26 02:47:57
【问题描述】:

如何为这个网址制定网址重写规则: example.com/account/login.aspx

到这个网址: me.example.com/login

因此,对文件夹 /account 的任何请求都将重写到 me.example.com。像 /account/subfoler/file1.aspx 这样的子文件夹和文件也会重写为 me.example.com/subfolder/file1

我已经为应用设置了 DNS 通配符,所有子域都将使用相同的 IP 地址。我需要的只是 url 重写规则。

【问题讨论】:

    标签: asp.net url-rewriting


    【解决方案1】:

    您可以在 IIS 7.0 Url Rewrite 中实现这一点

    编写你自己的处理程序来拦截传入的请求

    为此,您可以实现 IHttpHandler 并在 ProcessRequest 方法中处理 url 重定向逻辑

    这是一个很好的例子http://www.codeproject.com/Articles/30907/The-Two-Interceptors-HttpModule-and-HttpHandlers

    【讨论】:

      猜你喜欢
      • 2012-01-03
      • 2023-03-20
      • 1970-01-01
      • 2014-11-14
      • 2012-09-17
      • 1970-01-01
      • 2023-03-28
      • 2014-05-15
      相关资源
      最近更新 更多