[英]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.