[英]Url rewriting in asp.net?
我正在处理asp.net Web应用程序。
请指导我在asp.net中进行网址重写:
我需要更改以下链接
http://www.faredepot.com/ViewArticle.aspx?aid=1
至
http://www.faredepot.com/Cheap_Flights_to_Atlanta.html
我怎样才能做到这一点我尝试如下
void Application_BeginRequest(object sender, EventArgs e) {
string fullOrigionalpath = Request.Url.ToString();
if (fullOrigionalpath.Contains("http://www.faredepot.com/Cheap_Flights_to_Atlanta.html")) {
Context.RewritePath("http://www.faredepot.com/ViewArticle.aspx?aid=1");
}
}
否则尝试在web.config中执行此操作
<rewriter>
<rewrite url="http://www.faredepot.com/ViewArticle.aspx?aid=1" to="http://www.faredepot.com/Cheap_Flights_to_Atlanta.htm" />
</rewriter>
您对这里所有可能的解决方案都有很好的了解: http : //weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
您正在使用哪个版本的IIS? 对于IIS7使用自己的URL重写模块,并使用II6 Intelligencia UrlRewriter.NET: http://urlrewriter.net/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.