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. fastDFS的入门程序

    导入jar包 <dependency> <groupId>cn.bestwu</groupId> <artifactId>fastdfs-client- ...

  2. VS2017 Git failed with a fatal error. error: open(".vs/xxxxxx/v15/Server/sqlite3/db.lock"): Permission denied fatal: Unable to process path .vs/xxxxxx/v15/Server/sqlite3/db.lock

    具体错误信息:Git failed with a fatal error. error: open(".vs/xxxxxx/v15/Server/sqlite3/db.lock") ...

  3. 安装Windows 2008 操作系统时加载ServeRAID-MR10系列阵列卡驱动

    安装Windows 2008 操作系统时加载ServeRAID-MR10系列阵列卡驱动 适用机型: 所有System x3200 M2; 所有System x3250 M2; 所有System x33 ...

  4. Django:web认识,jinja2模块,如何安装Django

    一内容概要 1.HTTP协议 1.1简介 ​ 超文本传输协议(英文:Hyper Text Transfer Protocol,HTTP)是一种用于分布式.协作式和超媒体信息系统的应用层协议.HTTP是 ...

  5. 'adb' 不是内部或外部命令,也不是可运行的程序 或批处理文件—解决方法

    Windows键 + R → 输入cmd → 输入adb,提示“adb不是内部或外部命令,也不是可运行的程序 或批处理文件“,错误信息如下: 解决方法: 此电脑(右击)→ 属性 → 高级系统设置 → ...

  6. java git .gitignore常用规则

    # Created by .ignore support plugin (hsz.mobi).gitignore # Operating System Files *.DS_Store Thumbs. ...

  7. javascript 四舍五入; js 四舍五入

    方法 Math.round round() 方法可把一个数字舍入为最接近的整数. 对于 0.5,该方法将进行上舍入. 例如,3.5 将舍入为 4,而 -3.5 将舍入为 -3. Math.round( ...

  8. Linux Shell 小数比较

    #!/bin/bash #######expr 方法是错误的,在比较相同位数时可以,当位数不同就会出错,如100.00>70.00就会得出错误的结果 a=123b=123c=99.99rat=` ...

  9. ldconfig 让安装的 php 的rdkafka生效

    原文:https://www.cnblogs.com/schips/p/10183111.html linux中ldconfig的使用介绍   ldconfig是一个动态链接库管理命令,其目的为了让动 ...

  10. iptables常用命令二之如何删除nat规则

    删除iptables nat 规则 删除FORWARD 规则: iptables -nL FORWARD --line-number iptables -D FORWARD 1 删除一条nat 规则 ...