页面静态化的目地是为人SEO
下面这个.net 静态化不太正确,
<configuration>
<!--URL重写 1 此项必须放在 configuration中的第一位 Begin-->
<!--先在项目中引用 URLRewriter-->
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<!--URL重写 1 End-->
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--URL重写 2 注意是在 system.web中 Begin-->
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
<!--URL重写 2 End-->
</system.web>
<!--URL重写 3 配置规则 Begin-->
<RewriterConfig>
<Rules>
<!-- RewriterRule 中为配置规则 一个配置规则对应一对"RewriterRule" -->
<RewriterRule>
<LookFor>~/(\d{4})/(\d{2})/Default\.aspx</LookFor>
<SendTo>~/Default.aspx?ID=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/index.html</LookFor>
<SendTo>~/Index.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<!-- 把 ?page=2 格式转为 site.aspx site.aspx?page=2-->
<LookFor>~/(.[0-9]*)\.html</LookFor>
<SendTo>~/site.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/news/details_(/d+)_(/d+).html</LookFor>
<SendTo>~/news/details.aspx?tid=$1&nid=$2</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/news/index.html</LookFor>
<SendTo>~/news/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/news/list_(/d+).html</LookFor>
<SendTo>~/news/list.aspx?tid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/(.*).html</LookFor>
<SendTo>~/$1.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<!--URL重写 3 配置规则 End-->
</configuration>