当前位置:首页 > Windows程序 > 正文

win7 IIS7.5配置伪静态

2021-03-28 Windows程序

第一部: 
从如下地址中下载URLRewriter组件组件:

官方下载地址:

第二部:在网站项目中添加URLRewriter程序集的引用。

第三部:配置webconfig文件:

注意事项:1、参数用()括起来,使用 $1 来获得参数。2、多个参数的时候使用&分割。

1。在<configuration>与</configuration>节点中间加入如下配置:

<configSections>

       <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />

   </configSections>

 

2。 在<system.web>与</system.web> 之间加入

<httpHandlers>

          <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />

          <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />

 </httpHandlers>

 

或者

<system.web>                         

  <httpModules>                          

   <add type=”URLRewriter.ModuleRewriter, URLRewriter” name=”ModuleRewriter”/>                       

  </httpModules>                         

 </system.web>                                                                                   

 

  

3。配置伪静态的语法:在<configuration>与</configuration>之间加入<RewriterConfig> </RewriterConfig>节点。  

在  <RewriterConfig>与</RewriterConfig>之间加入伪静态规则:      <Rules> <!–定义伪静态第一条规则开始–> <RewriterRule> <LookFor>~/xxxx/view(.[\d]*)\.html</LookFor> <SendTo>~/xxxx/view.aspx?id=$1</SendTo> </RewriterRule>   <!–定义伪静态第一条规则结束–> <!–定义伪静态第二条规则开始–> <RewriterRule> <LookFor>~/yyyy/(.[\d]*)/view.html</LookFor> <SendTo>~/yyyy/view.aspx?id=$1</SendTo> </RewriterRule>

例子如:

<RewriterConfig> <Rules> <!--官网--> <RewriterRule> <LookFor>~/web/new/type-(.[0-9]*)\.html</LookFor> <SendTo>~/web/new.aspx?id=$1</SendTo> </RewriterRule> <RewriterRule> <LookFor>/index.html</LookFor> <SendTo>/index.aspx</SendTo> </RewriterRule> <RewriterRule> <LookFor>/aboutus/aboutusContent-(.*).html</LookFor> <SendTo>/aboutus/aboutusContent.aspx?pageurl=$1</SendTo> </RewriterRule> <RewriterRule> <LookFor>/shop/GiftList-(.*)-(.*).html</LookFor> <SendTo>/shop/GiftList.aspx?nav=$1&amp;price=$2</SendTo> </RewriterRule> <RewriterRule> <LookFor>/shop/list-(.*)-(.*)-(.*).html</LookFor> <SendTo>/shop/list.aspx?nav=$1&amp;licno=$2&amp;orderby=$3</SendTo> </RewriterRule> <RewriterRule> <LookFor>/shop/list-(.*)-(.*)-(.*)-(.*).html</LookFor> <SendTo>/shop/list.aspx?nav=$1&amp;licno=$2&amp;orderby=$3&amp;price=$4</SendTo> </RewriterRule> </Rules> </RewriterConfig>

或者

<RewriterConfig>

      <rewriter>                       

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/69266.html