IIS 7和IIS 7.5及以后的版本估计都会使用web.config来实现伪静态规则,于是我们以前的伪静态文件必须更改。网上找了一圈,还没有发现比较全面的web.config伪静态规则,于是我们这里整理一份,供初次使用的朋友参考。

实现普通页面、带一个数字参数页面和带两个参数页面的伪静态!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
 
<rule name="Index" stopProcessing="true">
<match url="^index.html" />
<action type="Rewrite" url="index.php" />
</rule>
 
<rule name="Rule1" stopProcessing="true">
<match url="^news_([0-9]+).html" />
<action type="Rewrite" url="news.php?nid={R:1}" />
</rule>
   
<rule name="Rule2" stopProcessing="true">
<match url="news_list_([0-9]+)_([0-9]+).html" />
<action type="Rewrite" url="news_list.php?nid={R:1}&page={R:2}" />
</rule>
 
</rules>
</rewrite>
</system.webServer>
</configuration>

IIS 7.5通过web.config实现301重定向的方法,将不带www的域名转向到带www的域名上!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
 
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^chuangluo.com$" />
</conditions>
<action type="Redirect" url="http://www.chuangluo.com/{R:0}" redirectType="Permanent" />
</rule>
 
</rules>
</rewrite>
</system.webServer>
</configuration>

由于我们的网站使用了转义字符,因此在实际使用的时候,大家不可以直接复制以上代码。请复制粘贴到Dreamweaver等编辑器后,使用替换功能把双引号全部替换为英文状态下的双引号,然后再修改rule标签内的内容就可以了,跳转的地方请更改为自己的网址即可。

需要注意的地方是以前httpd.ini和.htaccess支持网址中两个参数用&符号链接,在web.config中是不支持的,需要将这个符号更改为&才能正常使用。

原文链接:http://www.jb51.net/article/42901.htm

最新文章

  1. unity 实现简单的分离
  2. mysql基础面试
  3. C#中XmlTextWriter读写xml文件详细介绍(转)
  4. 基于tiny4412的Linux内核移植 -- 设备树的展开
  5. CONTROLS: &lt;&gt; TYPE TABLEVIEW USING SCREEN&lt;&gt;.在 ABAP/4 中声明表格 控制
  6. iptables中规则的关系——以只允许某些IP段访问为例
  7. 【Linux】CentOS系统
  8. SQL函数学习(二):DATEADD() 函数
  9. DBA Scripts
  10. how tomcat works 读书笔记 十一 StandWrapper 上
  11. C# out ref 用法总结
  12. PHP定界符eof 的使用
  13. python金融反欺诈-项目实战
  14. JS设计模式(5)发布订阅模式
  15. Practice2 结对子之“小学四则运算”
  16. topcoder srm 702 div1 -3
  17. pop_heap(_RAIter,_RAIter,_Compare)
  18. 理解dynamic programming动态规划
  19. 通用的将Excel导入数据集的方法
  20. 007-spring cache-缓存实现-02-springboot ehcahe3实现、springboot caffeine实现

热门文章

  1. mvc Area(区域)相关技术
  2. input输入框中只能输入数字,非数字字符自动清除
  3. 存储器的保护(二)——《x86汇编语言:从实模式到保护模式》读书笔记19
  4. 微信小程序-tab标签栏实现教程
  5. 事务的编写规范与Hibernate绑定session
  6. Appium移动端自动化测试-安卓真机+模拟器启动
  7. 周记2——ios的日期格式bug
  8. spring-boot之简单定时任务
  9. mongodb操作之mongoose
  10. 预防XSS方法:HtmlEncode和JavaScriptEncode(转)