下載地址:http://download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/MSDNURLRewriting.msi
UrlRewriter 是微軟封裝好了的一個URL重寫組件。使用它可以讓我節約很多自已開發的時間。
好了,開始講述我的應用經驗,這只是很菜鳥的經驗,高手就不用看了。
第一步,請從此下載此組件。解壓,把UrlRewriter.dll copy到你的項目 bin 目錄下。
第二步,在Web.config中加入:
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<!-- Rules for Blog Content Displayer -->
<RewriterRule>
<LookFor>~/read/(.[0-9]*)\.ASPx</LookFor>
<SendTo>~/read.ASPx?aid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/read/(.[0-9]*)\.Html</LookFor>
<SendTo>~/read.ASPx?aid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/read/(.[0-9]*)\.htm</LookFor>
<SendTo>~/read.ASPx?aid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/read/(.[0-9]*)\.do</LookFor>
<SendTo>~/read.ASPx?aid=$1</SendTo>
</RewriterRule>
<RewriterRule>