.NET URL重写 本帖最后由 skyqingtian 于 2010-03-31 22:57:46 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也不会,URL重写有什么好处-----我的理解是:隐瞒事实真相 玩笑而已,请批评指正... 这个是我以前总结的希望对你有用啊。URL重定向的步骤:(1)在Bin中导入cuteeditor.lic 和URLRewriter.dll这两个包;(2)配置节点节点如下:1.在<configuration>中配置<configSections><section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/></configSections><RewriterConfig><Rules><RewriterRule><!--节点中的LookFor指的是假的地址,而SendTo中指向的是实际地址--><LookFor>~/do(\d+)\.jsp</LookFor><SendTo>~/ShowNews.aspx?id=$1</SendTo></RewriterRule></Rules></RewriterConfig>2.在<system.web>中配置<httpHandlers><add verb="*" path="*.jsp" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/></httpHandlers> web.config:<rewrite> <rules> <rule name="RewriteUserFriendlyURL_PackageTour_Details" stopProcessing="true"> <match url="^insight/([_0-9a-zA-z]+)/([_0-9a-zA-z]+).html$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="insight/insight.aspx?folder={R:1}&file={R:2}" /> </rule> </rules> </rewrite>index.aspx.cs:public partial class insight : System.Web.UI.Page{ public String PageContant = ""; protected void Page_Load(object sender, EventArgs e) { if (Request["folder"] != null && Request["file"] != null) { String FilePath = HttpContext.Current.Server.MapPath("~/insight/" + Request["folder"].ToString() + "/" + Request["file"].ToString() + ".htm" ); if (System.IO.File.Exists(FilePath)) { System.IO.StreamReader SR = new System.IO.StreamReader(FilePath); PageContant = SR.ReadToEnd(); } } if (PageContant.Length < 3) { PageContant = "page not found."; } }}必须在iis6.0以上,要安装url rewrite mould~我自己在用的,确定调试通过 这里两篇文章,希望对你有所帮助:IIS URL Rewriting 和 ASP.NET routing(上)http://www.cnblogs.com/blodfox777/archive/2010/01/04/iis-url-rewriting-and-aspnet-routing-1.htmlIIS URL Rewriting 和 ASP.NET routing(下)http://www.cnblogs.com/blodfox777/archive/2010/01/05/iis-url-rewriting-and-aspnet-routing-2.html 楼主可以研究一个 HttpHander 对象; Url重写又称“伪静态”,用的好的话,它可以将你的开发语言隐藏。楼主可以看看这个博客的内容:http://blog.csdn.net/badyue/archive/2007/04/10/1559090.aspx url重写成伪静态的,可以对搜索引擎稍微友好些,有利于seo,其实动态的url百度 google收录也挺好。建议楼主看写seo的url伪静态相关内容。推荐url重写控件UrlRewritingNet,很好用。 httpHandler 还没有怎么用熟悉啊! gridview 里面的imagefield 的DataAlternateTextField 问题 请高手看看这母版页 求ASP.NET Ajax视频教程全28讲每讲附课件及源码 String.Format格式化问题 ?? [急...]如何让DataGrid分页后每页都显示指定的PageSize行数? 求教一个正则表达式 我的机器是XP pro 版本,能不能支持一个网站是ASP。NET写的呢? oracle数据库连接? 也许很简单,我糊涂了。 ActiveReport控件做的报表,为什么页面会不停的刷新? 有什么好的工具编辑csv 关于缓存的问题 fck的问题
URL重写有什么好处-----我的理解是:隐瞒事实真相
玩笑而已,请批评指正...
URL重定向的步骤:
(1)在Bin中导入cuteeditor.lic 和URLRewriter.dll这两个包;
(2)配置节点
节点如下:
1.在<configuration>中配置
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<!--节点中的LookFor指的是假的地址,而SendTo中指向的是实际地址-->
<LookFor>~/do(\d+)\.jsp</LookFor>
<SendTo>~/ShowNews.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
2.在<system.web>中配置
<httpHandlers>
<add verb="*" path="*.jsp" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/>
</httpHandlers>
<rules>
<rule name="RewriteUserFriendlyURL_PackageTour_Details" stopProcessing="true">
<match url="^insight/([_0-9a-zA-z]+)/([_0-9a-zA-z]+).html$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="insight/insight.aspx?folder={R:1}&file={R:2}" />
</rule>
</rules>
</rewrite>
index.aspx.cs:public partial class insight : System.Web.UI.Page
{
public String PageContant = ""; protected void Page_Load(object sender, EventArgs e)
{
if (Request["folder"] != null && Request["file"] != null)
{
String FilePath = HttpContext.Current.Server.MapPath("~/insight/" + Request["folder"].ToString() + "/" + Request["file"].ToString() + ".htm" );
if (System.IO.File.Exists(FilePath))
{
System.IO.StreamReader SR = new System.IO.StreamReader(FilePath);
PageContant = SR.ReadToEnd(); }
} if (PageContant.Length < 3)
{
PageContant = "page not found.";
}
}
}必须在iis6.0以上,要安装url rewrite mould~
我自己在用的,确定调试通过
http://www.cnblogs.com/blodfox777/archive/2010/01/04/iis-url-rewriting-and-aspnet-routing-1.htmlIIS URL Rewriting 和 ASP.NET routing(下)
http://www.cnblogs.com/blodfox777/archive/2010/01/05/iis-url-rewriting-and-aspnet-routing-2.html
建议楼主看写seo的url伪静态相关内容。推荐url重写控件UrlRewritingNet,很好用。