<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>守望轩 &#187; URL Rewrite</title>
	<atom:link href="http://www.watch-life.net/tag/url-rewrite/feed" rel="self" type="application/rss+xml" />
	<link>http://www.watch-life.net</link>
	<description>关注IT,审视自我,守望生活, 宁静雅致的小轩馆.</description>
	<lastBuildDate>Mon, 23 Aug 2010 15:08:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>web developer tips (38):如何用请求失败记录追踪重写规则</title>
		<link>http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html</link>
		<comments>http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html#comments</comments>
		<pubDate>Thu, 27 Aug 2009 13:12:32 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Failed Request Tracing]]></category>
		<category><![CDATA[FRT]]></category>
		<category><![CDATA[URL Rewrite]]></category>
		<category><![CDATA[web developer tips]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/?p=437</guid>
		<description><![CDATA[原文地址：How to use Failed Request Tracing to trace Rewrite Rules。 IIS 7.0 请求失败跟踪(Failed Request Tracing (FRT)) 是功能强大的请求失败故障诊断工具。有感 FRT更多详细的内容，你可以查看：Troubleshooting Failed Requests Using Tracing in IIS 7.0 在你的网站一旦启动请求失败跟踪（FRT），执行如下操作就可以跟踪重写规则(rewrite rules): http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html 1、双击“Failed Request Tracing Rule”图标，打开FRT 规则列表。 2、单击“Add&#8230;‘,打开创建FRT的向导。 3、在第一个页面选择“All content (*)” 4、点击“next”在status code(s)项输入：200-399 5、点击“next”，在Providers 项选中“WWW Server”（其他不选中），在areas项选中“Rewrite”（其他不选中） 6、单击“Finish”保存FRT 规则。 FRT规则创建后，记录（log）文件将会在%SystemDrive%\inetpub\Logs\FaileReqLogFiles\ 目录下生成。你可以用IE浏览器打开日志文件。 注意：请求失败跟踪(Failed Request Tracing (FRT)) 是安装在Url 重写模块（Url rewrite module之后，那么“Rewrite” 区域无法使用，你可以在&#8221;添加/删除程序”来重新安装Url [...]]]></description>
			<content:encoded><![CDATA[<p>原文地址：<a href="http://blogs.msdn.com/webdevelopertips/archive/2008/12/28/tip-38-did-you-know-how-to-use-failed-request-tracing-to-trace-rewrite-rules.aspx" target="_blank">How to use Failed Request Tracing to trace Rewrite Rules。</a></p>
<p>IIS 7.0 请求失败跟踪(Failed Request Tracing (FRT)) 是功能强大的请求失败故障诊断工具。有感 FRT更多详细的内容，你可以查看：<a href="http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-70/" target="_blank">Troubleshooting Failed Requests Using Tracing in IIS 7.0</a></p>
<p>在你的网站一旦启动请求失败跟踪（FRT），执行如下操作就可以<a href="http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html" target="_blank">跟踪重写规则</a>(rewrite rules):<br />
<a href="http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html" target="_blank">http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html</a></p>
<p><strong>1、双击“Failed Request Tracing Rule”图标，打开FRT 规则列表。</strong><br />
<img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="443" alt="frt" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.HowtouseFailedRequestTracingtotraceR_A70F/frt_thumb.png" width="544" border="0" /></p>
<p><strong>2、单击“Add&#8230;‘,打开创建FRT的向导。</strong><br />
<img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="385" alt="frt1" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.HowtouseFailedRequestTracingtotraceR_A70F/frt1_thumb.png" width="504" border="0" /></p>
<p><strong>3、在第一个页面选择“All content (*)”</strong></p>
<p><strong>4、点击“next”在status code(s)项输入：200-399</strong><br />
<img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="385" alt="frt2" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.HowtouseFailedRequestTracingtotraceR_A70F/frt2_thumb.png" width="504" border="0" /></p>
<p> <strong>5、点击“next”，在Providers 项选中“WWW Server”（其他不选中），在areas项选中“Rewrite”（其他不选中）</strong></p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="383" alt="frt3" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.HowtouseFailedRequestTracingtotraceR_A70F/frt3_thumb.png" width="504" border="0" /></p>
<p><strong>6、单击“Finish”保存FRT 规则。</strong></p>
<p>FRT规则创建后，记录（log）文件将会在%SystemDrive%\inetpub\Logs\FaileReqLogFiles\ 目录下生成。你可以用IE浏览器打开日志文件。</p>
<p>注意：请求失败跟踪(Failed Request Tracing (FRT)) 是安装在Url 重写模块（Url rewrite module之后，那么“Rewrite” 区域无法使用，你可以在&#8221;添加/删除程序”来重新安装Url 重写模块。</p>
<p>有关请求失败记录追踪重写规则的更多内容，详见：<a href="http://learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules/" target="_blank">Using Failed Request Tracing to Trace Rewrite Rules</a></p>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/visual-studio/turning-off-ie-s-enhanced-security-configuration.html" title="web developer tips (47):脚本远程调试需关闭IE增强安全配置 (2009-09-13)">web developer tips (47):脚本远程调试需关闭IE增强安全配置</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/there-are-several-new-configuration-settings-available-in-fastcgi-extension-1-5-beta.html" title="web developer tips (71): 关于FastCGI 1.5beta几个新配置设置 (2010-01-07)">web developer tips (71): 关于FastCGI 1.5beta几个新配置设置</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/set-a-fixed-port-for-the-developer-web-server.html" title="web developer tips (21):为Developer Web Server设定固定端口 (2009-07-14)">web developer tips (21):为Developer Web Server设定固定端口</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/change-the-dynamicdata-folder-location.html" title="web developer tips (45):如何改变动态数据文件夹的位置 (2009-09-09)">web developer tips (45):如何改变动态数据文件夹的位置</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/know-how-to-scope-master-pages.html" title="web developer tips (40):定义母版页的作用范围 (2009-08-31)">web developer tips (40):定义母版页的作用范围</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/how-to-sort-data-using-a-listview-control.html" title="web developer tips (7):在ListView控件里对数据排序 (2009-06-17)">web developer tips (7):在ListView控件里对数据排序</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/you-can-get-the-name-of-the-calling-method-from-the-stack-using-reflection.html" title="web developer tips (83):通过反射从堆栈里获取调用的方法名称 (2010-03-29)">web developer tips (83):通过反射从堆栈里获取调用的方法名称</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/create-an-iis-virtual-directory-from-within-visual-web-developer.html" title="web developer tips (12):在Visual Web Developer里创建IIS虚拟目录 (2009-06-26)">web developer tips (12):在Visual Web Developer里创建IIS虚拟目录</a> (0)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：0 | <b><a href='http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/visual-studio/use-failed-request-tracing-to-trace-rewrite-rules.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>web developer tips (34)：在IIS7.0使用网址重写防止盗链</title>
		<link>http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html</link>
		<comments>http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html#comments</comments>
		<pubDate>Thu, 13 Aug 2009 14:53:53 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[hot-linking]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[URL Rewrite]]></category>
		<category><![CDATA[web developer tips]]></category>
		<category><![CDATA[地址重写]]></category>
		<category><![CDATA[盗链]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/?p=429</guid>
		<description><![CDATA[原文地址：How to stop hot-linking from your site using URL Rewrite in IIS 7.0 一个热链直接链接到网站文件(图片，视频等),例如使用一个&#60;img&#62;标签显示一个任何人都可以在你网站发现的jpge图片，这也可以称之为盗链，当有人浏览这个网站的时候，将使用使用你的网站的带宽来显示JPEG图片。 如果在你的网站用下面这个具有版权的图片http://www.contoso.com/img1.jpg，将会被保护防止热链。 使用IIS7.0 的网址重写模块(URL Rewrite module )可以实现很简单的实现这个目的。让我告诉你如果通过IIS管理器来做到这一点。打开IIS管理器，选择你的网站（本例是 Contoso.com ），在“功能视图”单击“URL Rewrite”，然后单击“add rules&#8230;”,在“add rules”窗口选择“Blank Rule”，打开“Edit Rule”属性页，填写属性页如下图所示： http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html 解释一下关于这个属性也填写的内容： 1、指定规则的名称为：Prevent Leeching，这个名字必须是唯一规则名。 2、每个请求的URL的匹配模式为“.*”,是一个正则表达式。 3、增加两个条件，并使这两个条件能够得到满足。 （看“Logical Grouping（逻辑组合）”是“Match All（匹配所有）”） HTTP_REFERRER 不能匹配为空，因为它直接定位到一张图片。 HTTP_REFERRER 不能匹配你的网站(本例是 http://www.contoso.com) 4、如果满足上述连个条件（显然以为意味着来自任何网站的请求），我们将会跳转到安排的其他任何图片。 一个很重要提示就是URL Rewrite模块是需要被安装才可以工作，你可以如下两个版本： x86版本：http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1691 x64版本：http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;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/ 更过有关IIS7.0的比较酷的功能的视频见channel9：http://channel9.msdn.com/pdc2008/ES14/ 你可能也会喜欢以下文章： [...]]]></description>
			<content:encoded><![CDATA[<p>原文地址：<a href="http://blogs.msdn.com/webdevelopertips/archive/2008/12/15/tip-34-did-you-know-how-to-stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.aspx" target="_blank">How to stop hot-linking from your site using URL Rewrite in IIS 7.0</a></p>
<p>一个热链直接链接到网站文件(图片，视频等),例如使用一个&lt;img&gt;标签显示一个任何人都可以在你网站发现的jpge图片，这也可以称之为盗链，当有人浏览这个网站的时候，将使用使用你的网站的带宽来显示JPEG图片。</p>
<p>如果在你的网站用下面这个具有版权的图片<a href="http://www.contoso.com/img1.jpg" target="_blank">http://www.contoso.com/img1.jpg</a>，将会被保护<a href=" http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html" target="_blank">防止热链</a>。</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="177" alt="welcome" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip34Didyouknow...Howtostophotlinkingf.0_13EC/welcome_thumb.png" width="244" border="0" /></p>
<p>使用IIS7.0 的网址重写模块(URL Rewrite module )可以实现很简单的实现这个目的。让我告诉你如果通过IIS管理器来做到这一点。打开IIS管理器，选择你的网站（本例是 Contoso.com ），在“功能视图”单击“URL Rewrite”，然后单击“add rules&#8230;”,在“add rules”窗口选择“Blank Rule”，打开“Edit Rule”属性页，填写属性页如下图所示：<br />
<img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="698" alt="Url_Rewrite" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip34Didyouknow...Howtostophotlinkingf.0_13EC/Url_Rewrite_thumb_1.jpg" width="529" border="0" /></p>
<p> <a href="http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html" target="_blank">http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html</a></p>
<p>解释一下关于这个属性也填写的内容：<br />
1、指定规则的名称为：Prevent Leeching，这个名字必须是唯一规则名。<br />
2、每个请求的URL的匹配模式为“.*”,是一个正则表达式。<br />
3、增加两个条件，并使这两个条件能够得到满足。 （看“Logical Grouping（逻辑组合）”是“Match All（匹配所有）”）<br />
HTTP_REFERRER 不能匹配为空，因为它直接定位到一张图片。<br />
HTTP_REFERRER 不能匹配你的网站(本例是 http://www.contoso.com)<br />
4、如果满足上述连个条件（显然以为意味着来自任何网站的请求），我们将会跳转到安排的其他任何图片。</p>
<p>一个很重要提示就是URL Rewrite模块是需要被安装才可以工作，你可以如下两个版本：</p>
<p>x86版本：<a href="http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=169" target="_blank">http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1691</a></p>
<p>x64版本：<a href="http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1692" target="_blank">http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1692</a></p>
<p>该模块（目前）只支持IIS7.0,你应该运行IIS7.0有利于使用它。如果你的项目是使用Visual Studio for Web Developers开发，那么项目应该配置成在iis7.0下运行，而不是其他的web服务器。</p>
<p>有关URL Rewrite模块的详细内容见：<a href="http://learn.iis.net/page.aspx/460/using-url-rewrite-module/" target="_blank">http://learn.iis.net/page.aspx/460/using-url-rewrite-module/</a></p>
<p>更过有关IIS7.0的比较酷的功能的视频见channel9：<a href="http://channel9.msdn.com/pdc2008/ES14/" target="_blank">http://channel9.msdn.com/pdc2008/ES14/</a></p>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/visual-studio/go-to-definition-is-supported-for-css-class.html" title="web developer tips (28):CSS class 也支持“转到定义” (2009-07-22)">web developer tips (28):CSS class 也支持“转到定义”</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/deploying-your-asp-net-web-application-debug-false-should-be-set-in-web-config.html" title="web developer tips (52):部署Asp.net web应用须设置debug为false (2009-09-27)">web developer tips (52):部署Asp.net web应用须设置debug为false</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/about-the-tag-navigator-feature.html" title="web developer tips (6):关于标记导航功能 (2009-06-14)">web developer tips (6):关于标记导航功能</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/cancel-a-remote-web-operation-in-visual-studio-2008.html" title="web developer tips (39):在Visual Studio 2008中取消远程web操作 (2009-08-28)">web developer tips (39):在Visual Studio 2008中取消远程web操作</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/turn-off-intellisense-for-html-css-editors.html" title="web developer tips (54):取消HTML/ CSS编辑器的智能提示 (2009-10-14)">web developer tips (54):取消HTML/ CSS编辑器的智能提示</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/use-vs2005-to-debug-with-ie8.html" title="web developer tips (51):使用vs2005和IE8进行调试 (2009-09-25)">web developer tips (51):使用vs2005和IE8进行调试</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/add-intellisense-from-script-libraries-for-js-files.html" title="web developer tips (35):为js文件中的脚本库添加智能提示 (2009-08-14)">web developer tips (35):为js文件中的脚本库添加智能提示</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/web-deployment-migrate-operation.html" title="web developer tips (46):使用Web Deployment Tool进行Web部署迁移 (2009-09-11)">web developer tips (46):使用Web Deployment Tool进行Web部署迁移</a> (0)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：1 | <b><a href='http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/visual-studio/stop-hot-linking-from-your-site-using-url-rewrite-in-iis-7-0.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>web developer tips (31):利用IIS 7.0的URL Rewrite 模块产生用户友好的URL</title>
		<link>http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html</link>
		<comments>http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html#comments</comments>
		<pubDate>Wed, 29 Jul 2009 15:48:51 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[URL Rewrite]]></category>
		<category><![CDATA[web developer tips]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/?p=425</guid>
		<description><![CDATA[原文地址：How to have user friendly URL using IIS 7.0 URL Rewrite module 很友好的URL地址，使访问的人很容易记住。要求你的用户记住“ http://www.contoso.com/article.aspx?id=342&#038;title=URL-Rewrite-Walkthrough” 这样的网址并不是件很美妙的事。如果给用户提供如下URL地址：http://www.contoso.com/article/342/URL-Rewrite-Walkthrough，就能更好引起共鸣和更容易被记住。 通过IIS URL Rewrite 模块（ URL Rewrite module）你可以很方便建立这一逻辑而不需要修改正在使用的Rewrite Maps代码.我将告诉你从IIS管理器里来实现。打开IIS管理器，选择“Default Web Site”,在“功能视图”单击“URL Rewrite”，然后在“操作”栏，单击“Add Rules&#8230;”，在“select a rule templates”对话框选择“Blank rule”，将打开“edit rule”属性页，按如下步骤定义实际的重写规则（rewrite rule）: http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html 1、规则名称。 2、匹配URL字符串所使用的模式。 3、设置条件选项。 4、模式匹配和所有条件检查成功后执行的操作。 为了实现下面的例子，“edit rule”属性页如下图所示： 规则的名称应该是唯一（不重复）的，匹配字符串“^article/([0-9]+)/([_0-9a-z-]+)”是正则表达式，将匹配满足一下标准的任何URL字符串： 1、开始于“article/”字符序列。 2、在“/”后包含一个或多个数字字符。 3、在第二个“/”后包含一个或多个字母或“_”或“-”。 因为我们创建一个支持重写URL的规则，因此规则类型是“Rewrite“。重写字符串（Rewrite UR）“article.aspx?id={R:1}&#038;title={R:2}”指定一个新值用于输入被重写的URL。参数我们使用“ {R:1} ”和“{R:2}”，他们将返回一组通过规则匹配定义的引用(reference)。关于返回引用( back reference)你可以参考：URL Rewrite Module Configuration Reference，有关创建重写规则的更多内容见：Creating rewrite [...]]]></description>
			<content:encoded><![CDATA[<p>原文地址：<a href="http://blogs.msdn.com/webdevelopertips/archive/2008/12/01/tip-31-did-you-know-how-to-have-user-friendly-url-using-iis-7-0-url-rewrite-module.aspx" target="_blank">How to have user friendly URL using IIS 7.0 URL Rewrite module</a></p>
<p>很友好的URL地址，使访问的人很容易记住。要求你的用户记住“ <a href="http://www.contoso.com/article.aspx?id=342&#038;title=URL-Rewrite-Walkthrough" target="_blank">http://www.contoso.com/article.aspx?id=342&#038;title=URL-Rewrite-Walkthrough</a>” 这样的网址并不是件很美妙的事。如果给用户提供如下URL地址：<a href="http://www.contoso.com/article/342/URL-Rewrite-Walkthrough" target="_blank">http://www.contoso.com/article/342/URL-Rewrite-Walkthrough</a>，就能更好引起共鸣和更容易被记住。</p>
<p>通过<a href="http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html" target="_blank">IIS URL Rewrite 模块</a>（ URL Rewrite module）你可以很方便建立这一逻辑而不需要修改正在使用的Rewrite Maps代码.我将告诉你从<a href="http://www.watch-life.net/tag/iis" rel="tag" target="_blank">IIS</a>管理器里来实现。打开IIS管理器，选择“Default Web Site”,在“功能视图”单击“URL Rewrite”，然后在“操作”栏，单击“Add Rules&#8230;”，在“select a rule templates”对话框选择“Blank rule”，将打开“edit rule”属性页，按如下步骤定义实际的重写规则（rewrite  rule）:</p>
<p><a href="http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html" target="_blank">http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html</a></p>
<p>1、规则名称。<br />
2、匹配URL字符串所使用的模式。<br />
3、设置条件选项。<br />
4、模式匹配和所有条件检查成功后执行的操作。</p>
<p>为了实现下面的例子，“edit rule”属性页如下图所示：</p>
<p><img height="589" src="http://learn.iis.net/Content_Cache/461/Add rule UI.png" width="602" /></p>
<p>规则的名称应该是唯一（不重复）的，匹配字符串“^article/([0-9]+)/([_0-9a-z-]+)”是正则表达式，将匹配满足一下标准的任何URL字符串：</p>
<p>1、开始于“article/”字符序列。<br />
2、在“/”后包含一个或多个数字字符。<br />
3、在第二个“/”后包含一个或多个字母或“_”或“-”。</p>
<p>因为我们创建一个支持重写URL的规则，因此规则类型是“Rewrite“。重写字符串（Rewrite UR）“article.aspx?id={R:1}&#038;title={R:2}”指定一个新值用于输入被重写的URL。参数我们使用“ {R:1} ”和“{R:2}”，他们将返回一组通过规则匹配定义的引用(reference)。关于返回引用( back reference)你可以参考：<a href="URL Rewrite Module Configuration Reference" target="_blank">URL Rewrite Module Configuration Reference</a>，有关创建重写规则的更多内容见：<a href="http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/" target="_blank">Creating rewrite rules for the URL Rewrite Module</a></p>
<p>一个很重要的就是<a href="http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html" target="_blank">URL Rewrite模块</a>是需要被安装才可以工作，你可以如下两个版本：</p>
<p>x86版本：http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1691</p>
<p>x64版本：http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1692</p>
<p>该模块（目前）只支持IIS7.0,你应该运行IIS7.0有利于使用它。如果你的项目是使用Visual Studio for Web Developers开发，那么项目应该配置成在iis7.0下运行，而不是其他的web服务器。</p>
<p>有关URL Rewrite模块的详细内容见：<a href="http://learn.iis.net/page.aspx/460/using-url-rewrite-module/" target="_blank">http://learn.iis.net/page.aspx/460/using-url-rewrite-module/</a></p>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/visual-studio/go-to-definition-is-supported-for-css-class.html" title="web developer tips (28):CSS class 也支持“转到定义” (2009-07-22)">web developer tips (28):CSS class 也支持“转到定义”</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/how-you-can-automatically-format-unformatted-html-on-paste-in-vs.html" title="web developer tips (59):粘贴时在VS中自动格式化HTML (2009-11-05)">web developer tips (59):粘贴时在VS中自动格式化HTML</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/visual-web-developer-2008-has-a-new-style-builder-dialog.html" title="web developer tips (10):Visual Web Developer 2008中新的样式生成器 (2009-06-23)">web developer tips (10):Visual Web Developer 2008中新的样式生成器</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/you-can-get-the-name-of-the-calling-method-from-the-stack-using-reflection.html" title="web developer tips (83):通过反射从堆栈里获取调用的方法名称 (2010-03-29)">web developer tips (83):通过反射从堆栈里获取调用的方法名称</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/how-to-easily-create-your-own-project-templates.html" title="web developer tips (32)：轻松地创建自己的项目模板 (2009-08-03)">web developer tips (32)：轻松地创建自己的项目模板</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/powerful-css-tools-to-create-manage-and-apply-styles.html" title="web developer tips (1):创建、管理、应用样式表的强大工具 (2009-05-19)">web developer tips (1):创建、管理、应用样式表的强大工具</a> (2)</li>
	<li><a href="http://www.watch-life.net/visual-studio/know-how-to-navigate-using-document-outline.html" title="web developer tips (78):使用文档大纲导航 (2010-03-28)">web developer tips (78):使用文档大纲导航</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/know-how-to-scope-master-pages.html" title="web developer tips (40):定义母版页的作用范围 (2009-08-31)">web developer tips (40):定义母版页的作用范围</a> (0)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：0 | <b><a href='http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>web developer tips (25):在iis7下规范URLs和重定向</title>
		<link>http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html</link>
		<comments>http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html#comments</comments>
		<pubDate>Sun, 19 Jul 2009 11:50:56 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[IIS7.0]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[URL Rewrite]]></category>
		<category><![CDATA[web developer tips]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/?p=416</guid>
		<description><![CDATA[原文地址：You can have canonical URLs and Redirects with IIS 7.0 规范的URLs 有利于搜索引擎优化（Search Engine Optimized,SEO）,人可以很容易理解 http://www.contoso.com 和http://contoso.com 是一样的。但是，许多的搜索引擎不会做这样的假设，会把它们作为两个分开的条目来对待。这样讲对它们进行等级区分，同时降低网站的整体相关性。 在iis7里面，你可以通过地址重写(URL Rewrite )来解决这个问题。在web.config里加入如下规则，所有用户访问http://contoso.com将会自动跳转到http://www.contoso.com &#60;configuration&#62; &#60;system.webServer&#62; &#60;rewrite&#62; &#60;rules&#62; &#60;rule name=&#34;WWW Redirect&#34; stopProcessing=&#34;true&#34;&#62; &#60;match url=&#34;.*&#34; /&#62; &#60;conditions&#62; &#60;add input=&#34;{HTTP_HOST}&#34; pattern=&#34;^contoso.com$&#34; /&#62; &#60;/conditions&#62; &#60;action type=&#34;Redirect&#34; url=&#34;http://www.contoso.com/{R:0}&#34; redirectType=&#34;Permanent&#34; /&#62; &#60;/rule&#62; &#60;/rules&#62; &#60;/rewrite&#62; &#60;/system.webServer&#62; &#60;/configuration&#62; 一个很重要事就是要使用“Permanent”(永久)定向。这样做很有帮助的是，任何人链接你的网站是使用的非www地址时，直接使搜索引擎的机器人在抓取作为永久移动的链接。新的url将会被定义为正确的地址，因此旧的非www地址将不会被索引。 在iis 7.0 的管理器界面生成刚才我粘贴的xml代码，也可以实现地址重写 (URL Rewrite)。 http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html 打开iis管理器 [...]]]></description>
			<content:encoded><![CDATA[<p>原文地址：<a href="http://blogs.msdn.com/webdevelopertips/archive/2008/11/20/tip-25-did-you-know-you-can-have-canonical-urls-and-redirects-with-iis-7-0.aspx" target="_blank">You can have canonical URLs and Redirects with IIS 7.0</a></p>
<p>规范的URLs 有利于搜索引擎优化（Search Engine Optimized,SEO）,人可以很容易理解 <a href="http://www.contoso.com/" target="_blank">http://www.contoso.com </a>和<a href="http://contoso.com/" target="_blank">http://contoso.com</a> 是一样的。但是，许多的搜索引擎不会做这样的假设，会把它们作为两个分开的条目来对待。这样讲对它们进行等级区分，同时降低网站的整体相关性。</p>
<p>在iis7里面，你可以通过地址重写(URL Rewrite )来解决这个问题。在web.config里加入如下规则，所有用户访问http://contoso.com将会自动跳转到http://www.contoso.com</p>
<div class=code>
&lt;configuration&gt;<br />
&lt;system.webServer&gt;<br />
&lt;rewrite&gt;<br />
&lt;rules&gt;<br />
&lt;rule name=&quot;WWW Redirect&quot; stopProcessing=&quot;true&quot;&gt;<br />
&lt;match url=&quot;.*&quot; /&gt;<br />
&lt;conditions&gt;<br />
&lt;add input=&quot;{HTTP_HOST}&quot; pattern=&quot;^contoso.com$&quot; /&gt;<br />
&lt;/conditions&gt;<br />
&lt;action type=&quot;Redirect&quot; url=&quot;http://www.contoso.com/{R:0}&quot; <br />
redirectType=&quot;Permanent&quot; /&gt;<br />
&lt;/rule&gt;<br />
&lt;/rules&gt;<br />
&lt;/rewrite&gt;<br />
&lt;/system.webServer&gt;<br />
&lt;/configuration&gt;
</div>
<p>一个很重要事就是要使用“Permanent”(永久)定向。这样做很有帮助的是，任何人链接你的网站是使用的非www地址时，直接使搜索引擎的机器人在抓取作为永久移动的链接。新的url将会被定义为正确的地址，因此旧的非www地址将不会被索引。</p>
<p>在iis 7.0 的管理器界面生成刚才我粘贴的xml代码，也可以实现<a href="http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html" target="_blank">地址重写</a> (URL Rewrite)。<br />
<a href="http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html" target="_blank">http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html</a><br />
打开iis管理器</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="198" alt="IIS_Manager" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.YoucanhavecanonicalURLsandRedirectsw_A5D6/IIS_Manager_thumb_1.jpg" width="244" border="0" /></p>
<p>单击URL Rewrite<br />
<img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="198" alt="Url_Rewrite" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.YoucanhavecanonicalURLsandRedirectsw_A5D6/Url_Rewrite_thumb_1.jpg" width="244" border="0" /></p>
<p>单击“Add Rules”，在“add Rules”对话框里选择“Blank rule”。<br />
<img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="167" alt="image" src="http://blogs.msdn.com/blogfiles/webdevelopertips/WindowsLiveWriter/Tip.YoucanhavecanonicalURLsandRedirectsw_A5D6/image_thumb_1.png" width="244" border="0" /></p>
<p>选择一个你喜欢的模式，选中“Action type”下拉框中的“Redirect”项，然后输入重定向的url。这样做将增加如上文所述（xml 配置代码）相同的内容。</p>
<p>一个很重要的就是URL Rewrite模块是需要被安装才可以工作，你可以如下两个版本：</p>
<p>x86版本：<a href="http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1691" target="_blank">http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1691</a></p>
<p>x64版本：<a href="http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1692" target="_blank">http://www.iis.net/downloads/default.aspx?tabid=34&#038;g=6&#038;i=1692</a></p>
<p>该模块（目前）只支持IIS7.0,你应该运行IIS7.0有利于使用它。如果你的项目是使用Visual Studio for Web Developers开发，那么项目应该配置成在iis7.0下运行，而不是其他的web服务器。</p>
<p>有关URL Rewrite模块的详细内容见：<a href="http://learn.iis.net/page.aspx/460/using-url-rewrite-module/" target="_blank">http://learn.iis.net/page.aspx/460/using-url-rewrite-module/</a></p>
<p>IIS在7.0以前的版本中，对于URL Rewrite的支持非常不好。</p>
<p>IIS 7.0 的URL Rewrite模块显然是向<a href="http://httpd.apache.org/" target="_blank">Apache</a>学习来的，甚至可以把Apache 下的. htaccess 文件中有关URL Rewrite规则导入到IIS 7.0 的URL Rewrite模块。有关这方面的内容参见：<br />
<a href="http://www.weijingtai.com/2009/05/18/iis7-url-rewrite-module/" target="_blank">IIS7-URL重写(URL Rewrite Module)</a></p>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/visual-studio/remote-debugging-waps-using-iis.html" title="web developer tips (17):远程调试使用IIS的web应用 (2009-07-06)">web developer tips (17):远程调试使用IIS的web应用</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/how-to-sort-data-using-a-listview-control.html" title="web developer tips (7):在ListView控件里对数据排序 (2009-06-17)">web developer tips (7):在ListView控件里对数据排序</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/create-nested-master-pages-using-vs-2008.html" title="web developer tips (33)：在vs2008里创建套嵌母版页 (2009-08-11)">web developer tips (33)：在vs2008里创建套嵌母版页</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/manage-web-site-configuration-through-a-web-interface.html" title="web developer tips (57):通过web界面管理web站点配置 (2009-10-30)">web developer tips (57):通过web界面管理web站点配置</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/establishing-a-remote-connection-to-a-iis-server-with-self-issued-certificate.html" title="web developer tips (41):用自颁发的证书连接到远程IIS服务器 (2009-09-02)">web developer tips (41):用自颁发的证书连接到远程IIS服务器</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/go-to-definition-is-supported-for-css-class.html" title="web developer tips (28):CSS class 也支持“转到定义” (2009-07-22)">web developer tips (28):CSS class 也支持“转到定义”</a> (0)</li>
	<li><a href="http://www.watch-life.net/visual-studio/maintain-scrollposition-after-post-back.html" title="web developer tips (75):PostBack后保持滚动条的位置 (2010-03-17)">web developer tips (75):PostBack后保持滚动条的位置</a> (1)</li>
	<li><a href="http://www.watch-life.net/visual-studio/have-user-friendly-url-using-iis-7-0-url-rewrite-module.html" title="web developer tips (31):利用IIS 7.0的URL Rewrite 模块产生用户友好的URL (2009-07-29)">web developer tips (31):利用IIS 7.0的URL Rewrite 模块产生用户友好的URL</a> (0)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：1 | <b><a href='http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/visual-studio/you-can-have-canonical-urls-and-redirects-with-iis-7-0.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.watch-life.net @ 2010-09-07 01:49:48 -->