zoukankan      html  css  js  c++  java
  • Intelligencia.UrlRewriter在IIS 7.0下的完全配置攻略

    在项目中,之前公司是使用IIS 7.0官方的URL重写模块,官方的使用说明请参见官方URLRewrite  ,添加伪静态支持,后来经理问我有没有涉及伪静态,我说之前项目中我一直是用Intelligencia.UrlRewriter,我觉得它蛮好用的,然后我就按领导的意思换成这个,我以为这东西最多半个小时就搞定的事情,我之前都是在IIS 6.0上配置的。找过一些资料发现是webconfig中,多加两个配置。我在此记录下来。以便今后使用。

    1、在modules 结点添加runAllManagedModulesForAllRequests属性

    <modules runAllManagedModulesForAllRequests="true">

    2、然后在modules结果添加以下配置

    <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule"/>

    下面完整的介绍下配置步骤:

    一、配置webconfig

    第一步:在配置文件configSections结点中添加下面配置:

    <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>

    第二步:在httpModules结点内添加如下配置

    <!--配置url重写指定具体的处理组件-->
    
    <add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter"/>

    第三步:在modules 结点添加runAllManagedModulesForAllRequests属性

    <modules runAllManagedModulesForAllRequests="true">

    第四步:在modules结果添加以下配置

    <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule"/>

    重写规则的配置:有两种配置,一种是直接写在webconfig中,一种是写到一个xml中

    1、在webconfig中的配置:

    <rewriter>
        <rewrite url="~/default.html$" to="~/default.aspx" processing="stop" />
        <rewrtie url="^~/(d+)/(d+).html" to="~/Default.aspx?id=$1&amp;artcleid=$2" />//多个参数
    
    </rewriter>

    2、写到一个xml文件中,这样需要的webconfig指定到xml中

    如:

    <!--地址重写规则-->
      <rewriter file="~/xml/config/rewrite.xml"/>
    
    rewrite.xml中的内容如下:
    
    <?xml version="1.0" encoding="utf-8" ?>
     <rewriteRules>
       <!--注册日志监视器-->
       <register logger="Intelligencia.UrlRewriter.Logging.DebugLogger, Intelligencia.UrlRewriter" /> 
       <!--begin 网站首页 -->
    
      <rewrite url="~/index.html" to="~/Price_index.aspx" />
       <!--end 网站首页 -->
       <!--begin 新闻列表1(新闻类型) -->
       <rewrite url="~/newslist/([^/]*)/?$" to="~/price_newlist.aspx?type=$2" />
       <!--end 新闻列表1(新闻类型) -->
       <!--begin 新闻列表2(含分页) -->
       <rewrite url="~/newslist/([^/]*)-(d{1,3})/?$" to="~/price_newlist.aspx?type=$1&amp;page=$2" />
       <!--end 新闻列表2(含分页) -->
     </rewriteRules>

    到此介绍完毕,也许大家可能在用到这个的时候会遇到一个问题,那就是项目中本身的html文件无法访问,下次我为大家一一介绍解决办法。看到有需要用到的就参考下。

    这篇文章是在2012-06-09发表在csdn上的。点击查看

  • 相关阅读:
    scrapy 模块功能流程--转
    CP三次握手和四次分手--转
    获取免费IP--代码--转
    爬虫介绍+Jupyter Notebook--转
    In Ubuntu, How to install Chinese Pinyin with Fcitx?
    对json文件进行简单读写操作
    ubuntu 中wget (下载)命令用法
    如何更改Ubuntu 16.04 默认Python版本方法
    如何将本地文件上传通过命令行命令上传到远程服务器上
    Ubuntu上,如何成功的安装pygrib
  • 原文地址:https://www.cnblogs.com/naoguazi/p/URLReWriter.html
Copyright © 2011-2022 走看看