现在的位置: 网页制作教程网站制作教程 >正文
iis安装和问题

伪静态规则httpd.ini如何转换成web.config

发表于2016/12/8 网站制作教程 0条评论 ⁄ 热度 4,391℃

服务器升级,由原来的windows server2003换成了windows server2008,IIS也从6.0变成了7.0。

我们知道IIS6.0的伪静态规则是在httpd.ini文件中配置的。

而IIS7伪静态的配置是在web.config文件实现的。

所以IIS6升级到了IIS7,就面临着将httpd.ini中的伪静态规则转换成web.config的。

伪静态

下面是转换前后转换后的伪静态规则。

转换前的httpd.ini伪静态规则

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^/index\.html$ /index\.php [N,I]
RewriteRule ^(.*)/list-([0-9]+)\.html $1/list\.php\?PageNo=$2 [I]
RewriteRule ^(.*)/show-([0-9]+)\.html $1/show\.php\?uid=$2 [I]

转换后的web.config伪静态规则

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <staticContent>
    <mimeMap fileExtension=".bat" mimeType="text/bath" />
  </staticContent>
  <rewrite>
   <rules>
    <rule name="home Index">
      <match url="^index.html$" ignoreCase="false" />
      <action type="Rewrite" url="index.php" appendQueryString="false" />
    </rule> 
    <rule name="list Page">
      <match url="^(.*)list-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="{R:1}/.php?PageNo={R:2}" appendQueryString="false" />
    </rule>
    <rule name="show Page">
      <match url="^(.*)show-aid([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="{R:1}/show.php?uid={R:2}" appendQueryString="false" />
    </rule>
   </rules>
  </rewrite>
 </system.webServer>
</configuration>
  • 暂无评论