标签:
一,获得Mircosoft URLRewriter.dll(注意:此dll文件大小约为20KB,网上有8Kb的是不完整的文件,会报错)
二,在项目中该dll文件:添加引用(可以直接拷贝放入Bin文件夹即可)
三,web.config的配置,这部是非常关键的,也是静态化能否成功的关键。
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/web/product/(.[0-9]*).html</LookFor>
<SendTo>~/web/product.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/web/index.html</LookFor>
<SendTo>~/web/index.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
<compilation debug="true"/></system.web>
</configuration>
(<httpHandlers>要写在<system.web>里面):
四 配置IIS解析.html文件
internet信息服务-->右键点击属性 -->主目录 -->‘配置‘-->映射 -->找到.aspx的可执行文件路径 复制路径-->添加-->粘贴路径-->扩展名为".html"-->然后把检查文件是否存在的勾去掉这样就可以了,如果遇到“确定”按钮失效,可以用键盘事件编辑路径即可解决。

五:直接输入改变后的文件地址测试
标签:
原文地址:http://www.cnblogs.com/ki5s/p/4474986.html