【问题标题】:IIS rewrite rule to replace sub domain url to different url on same domainIIS 重写规则以将子域 url 替换为同一域上的不同 url
【发布时间】:2017-11-01 03:58:38
【问题描述】:
【问题讨论】:
标签:
asp.net
iis
url-rewriting
【解决方案1】:
使用 Global.asax 上的 BeginRequest,检查您的请求路径并采取相应措施 - 这是基于您的问题的示例。
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
string cTheFile = HttpContext.Current.Request.Path;
if (cTheFile.Contains("/reports/") && cTheFile.Contains("https://test."))
{
app.Response.Redirect(Request.RawUrl.Replace("https://test.","https://test2."), true);
return;
}
}
请注意避免此处出现无限循环。