我是iis网址重写模块中的新成员,我不是如何执行此操作。重写所有网址将aspx扩展名更改为html
,比如我有这个网址:
http://localhost/section.aspx?x=section1&IDSection=45
,我想这一点:
http://localhost/section~x~section11~IDSection~45.html
任何想法? 感谢您的帮助。
我是iis网址重写模块中的新成员,我不是如何执行此操作。重写所有网址将aspx扩展名更改为html
,比如我有这个网址:
http://localhost/section.aspx?x=section1&IDSection=45
,我想这一点:
http://localhost/section~x~section11~IDSection~45.html
任何想法? 感谢您的帮助。
这是在使用IIS7 URL重写模块的溶液:
你需要做的是写一个处理程序。这样你可以捕获扩展,然后根据需要解析它。这对用户是不可见的。 Handler绝对是您想要的方式,就像您使用URL路由一样,您仍然需要在IIS中将处理程序从aspx更改为html。
我会看这个解决方案 – camaya
可以做到这一点在c#中在ASP.NET中的URL中使用自定义扩展。
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
if (app.Request.Path.ToLower().IndexOf(".html") > 0)
{
string rawpath = app.Request.Path;
string path = rawpath.Substring(0, rawpath.IndexOf(".html"));
app.Context.RewritePath(path+".aspx");
}
}
我能否提供使用[路由](http://msdn.microsoft.com/en-us/magazine/dd347546.aspx),并且具有诸如'HTTP一个url://本地主机/部分/ 1/45' –
我的网址已经很好地定位于这种格式,如果我改变了,这可能会影响我的排名。 问题是因为我从iis6迁移到iis7。 – camaya
使用波形符号“(?)”代替问号“(?)”并不能真正使您的查询字符串变得更漂亮。事实上,我认为它更不直观。不仅如此,但任何你改变你的url字符串的方式,你正在影响排名。 –