【发布时间】:2011-11-27 19:40:22
【问题描述】:
我已经有一个 ASP.NET 网站
我想将我的网站更改为对 SEO 网址更友好。
我想改变前任。这个网站: www.mydomain.aspx?articleID=5
到: www.mydomain/article/learningURLrewrite - articlename 需要从数据库中读取
我该如何做到这一点?
我已经尝试过谷歌的一些文章,其中提到 IhttpModule 没有任何运气。
我的目标是有一个类负责基于文件夹路径进行重定向(像这样):
string folderpath = "my folderpath" (could be articles, products etc.)
string id = Request.QueryString["id"].ToString();
if(folderpath.equals("articles"))
{
string name = //find name from id in DB
//redirect user to www.mydomain/article/name
}
if(folderpath.equals("products"))
{
string name = //find name from id in DB
//redirect user to www.mydomain/products/name
}
我还想删除 aspx 扩展名
【问题讨论】:
-
你能告诉你正在使用哪个版本的 iis,以及 .net 框架的版本。因为答案取决于这些东西。
-
忘了说是.net 3.0
-
我找到了这个网站thecodebug.com/?p=363 它建议创建一个处理重写的类。我想我会继续这样做,并在每次用户发送请求时为 id 调用数据库。如果有更好的方法请告诉我。
标签: asp.net url-rewriting seo