.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 还没有怎么用熟悉啊! 结束excel进程问题 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! javascript:window.open(url)错误提示 [复合控件] 如何把两个web控件做成一个web控件? 关于ASP.NET中图片路径的问题 各位版主进,关于论坛改进的问题 删除目录的问题,急问! 请教一个ASP.net调试的问题!!!感谢!! 怎么在Menu上加背景图 求《asp.net交互式Web数据库程序设计》源码--铁道出版社出版 DataGrid 问题 望大家救我 关于缓存的问题 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,很好用。