IIS7 做伪静态比较的简单方便

1.程序方面
只需要设置web.config 就可以了。
2.服务器需要安装:URL Rewrite
下载地址:http://www.iis.net/download/URLRewrite
Godaddy 的主机已经安装这个插件。
本地在测试的时候 请查看自己是否安装这个插件。
 
注意要点
1.参数用“()” 括起来 ,使用 {R:1}来获得参数
2.多个参数中间用 & 分割
3.name切记不能写一样 
<?xml version="1.0"?>

<configuration>
<system.webServer>
<rewrite>
<rules>
<!--301重定向把不带3W的域名 定向到带3W-->
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^haoxinwen.info$" />
</conditions>
<action type="Redirect" url="http://www.haoxinwen.info/{R:0}" redirectType="Permanent" />
</rule>
<!--首页-->
<rule name="rD">
<match url="^$" />
<action type="Rewrite" url="Default.aspx" />
</rule>
<!--产品列表-->
<rule name="rP">
<match url="^product/$" />
<action type="Rewrite" url="ProductList.aspx" />
</rule>
<!--产品列表第几页-->
<rule name="rPL">
<match url="^product/list-([0-9]*).html$" />
<action type="Rewrite" url="ProductList.aspx?page={R:1}" />
</rule>
<!--产品类别列表-->
<rule name="rPT">
<match url="^product/([A-Za-z0-9-]*)/$" />
<action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}" />
</rule>
<!--产品类别列表第几页-->
<rule name="rPTL2">
<match url="^product/([A-Za-z0-9-]*)/list-([0-9]*).html$" />
<action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}&page={R:2}" />
</rule>
<!--产品详细-->
<rule name="rPd">
<match url="^product/([A-Za-z0-9-]*)/([A-Za-z0-9-]+).html$" />
<action type="Rewrite" url="ProductDetail.aspx?typeUrl={R:1}&url={R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

  

IIS7 伪静态 web.config 配置方法
iis6 伪静态 iis配置方法 图解
iis6 web.config 伪静态配置方法

举个栗子:

安装URL Rewrite

在iis新建了一个叫做hello的站点,端口:8088

站点目录新建一个index.html文件

<h1>hello world</h1>

  

启动站点,浏览器输入:http://localhost:8088/

ok,站点已经成功运行

打开站点目录,新建一个web.config 文件

<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!--我的规则-->
<rule name="myrule">
<match url="^hello$" />
<action type="Rewrite" url="index.html" />
</rule>
<!--我的规则2-->
<rule name="myrule2">
<match url="^jy/good$" />
<action type="Rewrite" url="jy/good.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

ps:安装 URL Rewrite 后才可以使用rewrite标签

启动站点,打开浏览器,输入路由地址:http://localhost:8088/jy/good

然后会匹配到站点的 jy/good.html 文件,如下:

good.html

<h1>Good</h1>

  

浏览器显示:

参考:https://www.cnblogs.com/yanzhen/archive/2012/01/07/iis7-wei-jing-tai.html

IIS7 伪静态 web.config 配置方法【详解】的更多相关文章

  1. IIS7 伪静态 web.config 配置方法

    <rule name="Redirect" stopProcessing="true"> <match url=".*" ...

  2. 局域网内远程连接OPC配置方法详解

    局域网内远程连接OPC配置方法详解 https://wenku.baidu.com/view/20fb8ea6d1d233d4b14e852458fb770bf78a3bcc.html   OPC服务 ...

  3. 【Python】Linux crontab定时任务配置方法(详解)

    CRONTAB概念/介绍 crontab命令用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于“crontab”文件中,以供之后读取和执行. cron 系统调度进程. 可以使用它在 ...

  4. Tomcat web.xml配置参数详解

    Apache Tomcat Configuration Reference - The Context Containerhttps://tomcat.apache.org/tomcat-5.5-do ...

  5. Linux操作系统下IPTables配置方法详解

    如果你的IPTABLES基础知识还不了解,建议先去看看. 们来配置一个filter表的防火墙 1.查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables -L -n Cha ...

  6. caffe-windows环境配置(github上官方BVLC/caffe的推荐配置方法详解)

    [转载来的文章:如有侵权,请联系我!我将马上删除!] 首先声明一下,如标题,本教程是caffe在windows系统上的配置方法,而且是github上官方BVLC/caffe目前推荐的配置方法,并不是使 ...

  7. CentOS防火墙iptables的配置方法详解

    CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助. iptables是与Linux ...

  8. servlet两种配置方法详解

     1.web.xml中Servlet的注解 <servlet> <!-- servlet的内部名称,自定义 --> <servlet-name>DemoAction ...

  9. servlet web.xml配置选项详解

    一般的web工程中都会用到web.xml,web.xml主要包括一些配置标签,例如Filter.Listener.Servlet等,可以用来预设容器的配置,可以方便的开发web工程.但是web.xml ...

随机推荐

  1. 进入恢复模式(Recovery HD)

    进入恢复模式(Recovery HD) 1,选中要启动的虚拟机,随后点击VM菜单的启动按钮后面向下箭头,随后点击菜单项”打开电源时进入固件“. 2,在虚拟机里面,用上下键移动到”Enter setup ...

  2. 压测工具wrk的编译安装与基础使用

    Linux上编译安装: [root@centos ~]# cd /usr/local/src [root@centos ~]# yum install git -y [root@centos ~]# ...

  3. js编写日历的思路

    首先写出一个日历我们需要考虑以下2个问题: 每个月的总天数 每个月的第一天周几 这里提供了一个判断平年闰年2月份天数的方法: function leapYear(year) { return (yea ...

  4. Part_five:Redis哨兵高可用

    redis哨兵高可用 1.redis-sentinel Redis-Sentinel是redis官方推荐的高可用性解决方案, 当用redis作master-slave的高可用时,如果master本身宕 ...

  5. Android目前流行三方数据库ORM分析及对比

    Android 平台上的数据库框架非常多,但是有一个共同特点就是基于对象关系映射(ORM)模型的.实现的目标也都是不需要写SQL语句,通过对对象的操作保存和操作数据.要是从语法的简洁性来说都有自己的特 ...

  6. centos 7.6 安装php70

    1.首先查看是否有老版本 yum list installed | grep php 2.如果安装的有,清除老版本 yum remove php.x86_64 php-cli.x86_64 php-c ...

  7. C++中string::find()函数和string::npos函数的使用

    1. string::find()函数和string::npos函数的介绍 我们在学习C++的时候必不可少的使用到string类中的find()函数,它是一个查找函数,功能还是很强大的,但是此处我们不 ...

  8. IDRAC 固件升级操:

    Internal Use - Confidential IDRAC 固件升级操作: R630:https://downloads.dell.com/FOLDER05590166M/1/iDRAC-wi ...

  9. FFmpeg---源码编译

    @https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu  , FFmpeg官方给出了详细的编译步骤 @https://legacy.gitbook. ...

  10. 实用mysql数据库命令

    连接:mysql -h主机地址 -u用户名 -p用户密码 (注:u与root可以不用加空格,其它也一样)断开:exit (回车) 创建授权:grant select on 数据库.* to 用户名@登 ...