惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
P
Proofpoint News Feed
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
The Last Watchdog
The Last Watchdog
F
Fortinet All Blogs
S
Schneier on Security
Help Net Security
Help Net Security
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Check Point Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
I
InfoQ
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
T
Troy Hunt's Blog
人人都是产品经理
人人都是产品经理
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
Forbes - Security
Forbes - Security
Vercel News
Vercel News
S
Security Affairs
美团技术团队
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Spread Privacy
Spread Privacy
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
U
Unit 42
Recorded Future
Recorded Future
W
WeLiveSecurity
PCI Perspectives
PCI Perspectives
P
Palo Alto Networks Blog
H
Hacker News: Front Page
S
Security @ Cisco Blogs
博客园 - 【当耐特】

博客园 - Elliott.Dong

数据库命名与注释规范 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法 - Elliott.Dong - 博客园 虚拟目录继承根Web.Config的问题解决(转) - Elliott.Dong - 博客园 win7下添加microsoft loopback adapter实现xp mode网络共享 sql server 2000日志文件收缩 jquery-autocomplete 参数说明 【转】启用Visual Studio 对jQuery的智能感知 - Elliott.Dong .net Remoting与Web Service的比较 VmWare虚拟机增加硬盘容量 转:sql server 2008收缩数据库日志 格式字符替换 - Elliott.Dong - 博客园 DataView 的 Distinct 功能 Windows 7中使用USB KEY 解决XP下不能识别USB鼠标问题 Silverlight 2 开发环境【转】 oracle trunc()函数的用法 处理Flex 页面的后退/前进/刷新/关闭事件 [备忘]Visual Studio常用小技巧 VS.Net中的快捷键技巧
【转】Windows7下IIS7.5的伪静态URL Rewrite安装配置和案例综合
Elliott.Dong · 2010-08-10 · via 博客园 - Elliott.Dong

安装:

关于Windows 7下IIS7.5的伪静态的介绍好像很少,一般都是Vista下的IIS7.0,不过好在IIS7.0和IIS7.5差别并不是很大,不过对于我这个直接从IIS5.1跳到IIS7.5的人来说还是有点小麻烦的,从5.1到7.5变化还是蛮大的。

实现asp.net网站整站伪静态化需要以下条件:
1.IIS7.0 (目前Url Rewrite Module仅支持IIS7);
2.Url Rewrite Module,下载地址:http://www.iis.net/expand/URLRewrite

下面说下IIS7.5下伪静态(Rewrite)的安装,安装很傻瓜式的,下载这个组件,下载好了直接安装下酒可以了。

安装好了之后我们打开IIS,即可在网站IIS的配置中看到 URL rewrite的选项

urlrewrite1

双击URL rewrite图标(前提是先选定左边“网站”目录下你想使用伪静态的那个本地测试网站目录,如图),然后我们就进入到了rewrite管理页面;
然后我们就进入到了rewrite规则管理页面;

urlrewrite2

点击Add Rules后我们即可进入添加规则页面,当然最简单的处理方式就是在本地写好一个 *.htaccess 规则文件,然后点击Import Rules导入就OK了。

案例:

很友好的URL地址,使访问的人很容易记住。要求你的用户记住“ http://www.pipima.com/article.aspx?id=342&;title=URL-Rewrite-Walkthrough” 这样的网址并不是件很美妙的事。如果给用户提供如下URL地址:http://www.pipima.com/article/342/URL-Rewrite-Walkthrough,就能更好引起共鸣和更容易被记住。
通过IIS URL Rewrite 模块( URL Rewrite module)你可以很方便建立这一逻辑而不需要修改正在使用的Rewrite Maps代码.我将告诉你从IIS管理器里来实现。打开IIS管理器,选择“Default Web Site”,在“功能视图”单击“URL Rewrite”,然后在“操作”栏,单击“Add Rules…”,在“select a rule templates”对话框选择“Blank rule”,将打开“edit rule”属性页,按如下步骤定义实际的重写规则(rewrite rule):
1、规则名称。
2、匹配URL字符串所使用的模式。
3、设置条件选项。
4、模式匹配和所有条件检查成功后执行的操作。
为了实现下面的例子,“edit rule”属性页如下图所示:

addrule

规则的名称应该是唯一(不重复)的,匹配字符串“^article/([0-9]+)/([_0-9a-z-]+)”是正则表达式,将匹配满足一下标准的任何URL字符串:
1、开始于“article/”字符序列。
2、在“/”后包含一个或多个数字字符。
3、在第二个“/”后包含一个或多个字母或“_”或“-”。
因为我们创建一个支持重写URL的规则,因此规则类型是“Rewrite“。重写字符串(Rewrite UR)“article.aspx?id={R:1}&title={R:2}”指定一个新值用于输入被重写的URL。参数我们使用“ {R:1} ”和“{R:2}”,他们将返回一组通过规则匹配定义的引用(reference)。关于返回引用( back reference)你可以参考:URL Rewrite Module Configuration Reference,有关创建重写规则的更多内容见:Creating rewrite rules for the URL Rewrite Module
一个很重要的就是URL Rewrite模块是需要被安装才可以工作,你可以如下两个版本:
x86版本:http://www.iis.net/downloads/default.aspx?tabid=34&;g=6&i=1691
x64版本:http://www.iis.net/downloads/default.aspx?tabid=34&;g=6&i=1692
该模块(目前)只支持IIS7.0,你应该运行IIS7.0有利于使用它。如果你的项目是使用Visual Studio for Web Developers开发,那么项目应该配置成在iis7.0下运行,而不是其他的web服务器。
有关URL Rewrite模块的详细内容见:http://learn.iis.net/page.aspx/460/using-url-rewrite-module/

注意:

1.原来的$1换成{R:1},其他语法少许变化<rewrite url="~/test/([a-zA-Z0-9_\-]+)/(\d+).html\?{0,1}(.*)$" to="~/test.aspx?id=$4&$5" processing="stop"/>
换成
<rule name="OrgPage" stopProcessing="true">
                <match url="^test/([a-zA-Z0-9_\-]+)/(\d+).html\?{0,1}(.*)$" />               
                <action type="Rewrite" url="test.aspx?id={R:1}&{R:2}" />
</rule>
2.UrlRewriter中 url="~/module/“ ,在URL Rewrite Module中必须换成^module/,否则就算test通过,在实际环境中也无法解析;
3.以前 UrlRewriter中 url="^/([a-zA-Z0-9_]+)“是可以的,但是在URL Rewrite Module中不行,必须添加参数
<conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_HOST}" pattern="^blog\.lehu\.shu\.edu\.cn$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
4.另外需要注意IIS6的config转换到iis7的时候,需要删除applicationHost.config中<handlers accessPolicy="Read, Script" />的多余参数,或者干脆重新建立,否则会出现很多奇怪的问题,我昨天为了这个搞了好几个小时,后来才发现问题。
总体上说,IIS7比IIS6稳定些了,到现在位置,IIS6中总是出现的缓冲池死在IIS7中很少出现。具体情况还需要测试。
另:
Microsoft URL Rewrite Module 下载地址:
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1692
Microsoft URL Rewrite Module Configuration的说明
http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/