Intelligencia.UrlRewriter相关资源整理
来源:互联网 发布:国家卫计委网络直报 编辑:程序博客网 时间:2024/06/06 05:21
1.Server2000/2003/XP操作系统下IIS的配置:
官网:http://urlrewriter.net/index.php/support/installation
2.UrlRewriter.net(入门篇)(进阶篇)(高级篇)代码示例:
下载:/Files/Fred_Xu/UrlRewriter.NET.rar
3.Intelligencia.UrlRewriter在IIS7、7.5中的配置方法:
在vista、win7、server2008中,iis的版本是v7+,IIS6重写配置在IIS7中重写无效解决方案由于IIS6只能在请求被分配到Asp.Net引擎后才能发生重写操作,IIS7可以在IIS请求管道的任何地方执行一个HttpModule, 而且IIS7对于文件或文件夹的访问权限得重新设置.
如果是IIS7.0/7.5的运行环境,添加该配置
<modules>
<!--您的自定义IIS重写模块操作-->
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule"/>
</modules>
</system.webServer>
问题即可解决!
摘引自ScottGu的Blog:
<configuration>
<configSections>
<sectionname="rewriter"
requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler,Intelligencia.UrlRewriter"/>
</configSections>
<system.web>
<httpModules>
<addname="UrlRewriter"type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter"/>
</httpModules>
</system.web>
<system.webServer>
<modulesrunAllManagedModulesForAllRequests="true">
<addname="UrlRewriter"type="Intelligencia.UrlRewriter.RewriterHttpModule"/>
</modules>
<validationvalidateIntegratedModeConfiguration="false"/>
</system.webServer>
<rewriter>
<rewriteurl="~/products/(.+)"to="~/products.aspx?category=$1"/>
</rewriter>
</configuration>
4.重写HTML的规则示例:
(1)
注意:
当使用通配符映射或者使用ASP.NET处理所有HTTP请求的时候,IIS的默认文档机制也就失去了该有的作用,以下代码就是用来重新实现默认文档的方法:
<rewrite url="^(.*)/(/?.+)?$" to="$1/default.aspx$2" />注意:使用“processing="restart"”的时候将会导致重写引擎从头开始执行所有的重写规则,此时应当注重包含“/default.aspx”字符串的处理。
如果你需要同时支持多个默认文档,那么以上代码需要修改为:
<if url="^(.*)/(/?.+)?$">
<rewrite exists="$1/default.aspx" to="$1/default.aspx$2" />
<rewrite exists="$1/index.aspx" to="$1/index.aspx$2" />
<rewrite exists="$1/index.html" to="$1/index.html$2" />
</if>编辑以上规则代码的时候,尤其要注意确认文件是否存在。
此外,在使用通配符映射或者使用ASP.NET处理所有HTTP请求的时候,你会发现.gif、.css等文件无法正常访问,这是因为此时对这些文件类型的处理都被ASP.NET所拦截。修正方法如下:
<rewrite
url="^(/.+(/.gif|/.png|/.jpg|/.ico|/.css|/.js)(/?.+)?)$"
to="$1" processing="stop" />两个比较特殊的正则表达式字符是“^”和“$”(不是必须的),“^”代表URL的开头,“$”代表URL的结尾。使用这两个符号可以使您更加精确的控制重写动作,以确保程序所匹配的URL正是您想处理的。
“~/”表示当前网站应用程序运行所在的虚拟根目录,当您把网站应用程序安装于虚拟目录(或者非根目录)的时候,这尤其有用,而无须重新编写任何代码来替换您的虚拟根路径。
模式匹配在处理查询字串(QueryStrings)的时候尤其有用,这可以让您的URL去掉类似于“?id=3”的代码段,这非常有用,可以让你轻松的实现伪静态。
下面列出两个我们认为非常有特色的重写规则:
(1) 当目标URL不包含自定义查询字串的时候:
<rewrite url="^~/mypage(/?.+)?$" to="~/default.aspx$1" />此时“$1”匹配的是(/?.+)?,也就是所有的查询字串。
(2) 当目标URL包含自定义查询字串的时候:
<rewrite url="^~/mypage(/?(.+))?$"
to="~/default.aspx?page=mypage&$2" />注意此时需要使用“&”来代替“&”,这是XML文档语法的需要。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/bl_song/archive/2009/11/03/4761343.aspx
(2)
<rewrite url="~/default.html$" to="~/default.aspx" processing="stop" />
<rewrtie url="^~/(/d+)/(/d+).html" to="~/Default.aspx?id=$1&artcleid=$2" />//多个参数
<rewrite url="~/news_([0-9]+).html$" to="~/Article/ArticleShow.aspx?id=$1" processing="stop" />
<rewrite url="~/Result_([0-9]+).aspx$" to="~/Job/Company/Result.aspx?cid=$1" processing="stop" />
<rewrite url="~/company_([0-9]+).html$" to="~/Company/$1/index.html" processing="stop" />
<rewrite url="~/Resume/([0-9]+)_([0-9]+).html$" to="~/Resume/$1/Resume_$2.html" processing="stop" />
<rewrite url="~/([0-9]+)_([0-9]+).html$" to="~/company/$1/job_$2.html" processing="stop" />
<rewrite url="~/job_([0-9]+).html$" to="~/company/$1/jobs_$1.html" processing="stop" />
<rewrite url="~/news_l([0-9]+)_1.html$" to="~/company/$1/$1_news.html" processing="stop" />
<rewrite url="~/news_([0-9]+)v([0-9]+).html$" to="~/company/$1/n_$2.html" processing="stop" />
<rewrite url="~/contact_([0-9]+).html$" to="~/company/$1/contact.html" processing="stop" />
<rewrite url="~/a_(.+)_(.+).aspx$" to="~/a.aspx?id=$1&id1=$2" processing="stop" />//多个参数
</rewriter>
5.博客园资源整理:
JeffreyZhao 赵劼的博文:
重提URL Rewrite(1):IIS与ASP.NET
重提URL Rewrite(2):使用已有组件进行URL Rewrite
重提URL Rewrite(3):在URL Rewrite后保持PostBack地址 //这篇文章对我帮助最大了,在实际项目中是一定要用到的。
重提URL Rewrite(4):不同级别URL Rewrite的一些细节与特点
- Intelligencia.UrlRewriter相关资源整理
- Intelligencia.UrlRewriter IIS7.5
- 使用Intelligencia.UrlRewriter重写URL
- [.NET] Intelligencia.UrlRewriter 2.0 配置
- Intelligencia.UrlRewriter使用说明(转)
- Intelligencia.UrlRewriter实现伪静态
- c# 地址重写 Intelligencia.UrlRewriter
- URLRewriter最简单入门介绍 URLRewriter相关资源
- URLRewriter最简单入门介绍 URLRewriter相关资源
- 利用Intelligencia.UrlRewriter.dll实现URL重写
- 利用Intelligencia.UrlRewriter.dll实现URL重写
- Intelligencia.UrlRewriter.dll实现URL重写
- Intelligencia.UrlRewriter,Log4net调用外部的配置文件
- 利用Intelligencia.UrlRewriter.dll实现URL重写1
- 利用Intelligencia.UrlRewriter.dll实现URL重写2
- Intelligencia.UrlRewriter简单介绍(urlRewrite组件使用简单介绍)
- 利用Intelligencia.UrlRewriter.dll实现URL重写2
- 利用Intelligencia.UrlRewriter.dll实现URL重写(伪静态)
- MFC中添加自定义消息
- Calendar 控件
- 生活充满了太多
- C#开发WPF/Silverlight动画及游戏系列教程
- sql server中用convert函数将日期型字段转换成字符串
- Intelligencia.UrlRewriter相关资源整理
- 使用jfreechart-1.0.13在jsp页面画3D柱状图表
- 正则表达式基本语法学习
- 右左法则
- 存储过程分页
- Common Files文件夹介绍
- 软件研发那些事儿——有效地收集需求
- Ubuntu安装相关
- zabbix研究 一、入门