IIS 7.5通过web.config设置伪静态规则方法

 is7.5下常见程序通过web.config实现伪静态新建一个以web.config命名的文件内容为

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
    <system.webServer>
<!–将下面的规则添加到这里–>
    </system.webServer>
</configuration>
  

记得后台的伪静态要开启喔

以shopex规则示例如下,选择需要的规则添加:

<!–shopex–>
<rewrite>
            <rules>
                <rule name=”disableDownloadThemeHtml”>
                    <match url=”^themes/.*.(html|xml)$”
ignoreCase=”false” />
                    <action type=”CustomResponse” url=”/”
statusCode=”403″ statusReason=”Forbidden” statusDescription=”Forbidden”
/>
                </rule>
                <rule name=”urlRewrite”>
                    <match url=”^(.*)$” ignoreCase=”false” />
                    <conditions logicalGrouping=”MatchAll”>
                        <add input=”{REQUEST_FILENAME}”
pattern=”.(html|xml|json|htm|php|php2|php3|php4|php5|phtml|pwml|inc|asp|aspx|ascx|jsp|cfm|cfc|pl|cgi|shtml|shtm|phtm)$”
ignoreCase=”false” />
                        <add input=”{REQUEST_FILENAME}”
matchType=”IsFile” negate=”true” pattern=”” ignoreCase=”false” />
                        <add input=”{REQUEST_FILENAME}”
matchType=”IsDirectory” negate=”true” pattern=”” ignoreCase=”false”
/>
                    </conditions>
                    <action type=”Rewrite” url=”index.php?{R:1}”
appendQueryString=”false” />
                </rule>
            </rules>
        </rewrite>
<!–dz2.0–>
<rewrite>
<rules>
  <rule name=”portal_topic”>
   <match url=”^(.*/)*topic-(.+).html\?*(.*)$” />
   <action type=”Rewrite”
url=”{R:1}/portal.php\?mod=topic&topic={R:2}&{R:3}” />
  </rule>
  <rule name=”portal_article”>
   <match
url=”^(.*/)*article-([0-9]+)-([0-9]+).html\?*(.*)$” />
   <action type=”Rewrite”
url=”{R:1}/portal.php\?mod=view&aid={R:2}&page={R:3}&{R:4}”
/>
  </rule>
  <rule name=”forum_forumdisplay”>
   <match url=”^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/forum.php\?mod=forumdisplay&fid={R:2}&page={R:3}&{R:4}”
/>
  </rule>
  <rule name=”forum_viewthread”>
   <match
url=”^(.*/)*thread-([0-9]+)-([0-9]+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/forum.php\?mod=viewthread&tid={R:2}&extra=page={R:4}&page={R:3}&{R:5}”
/>
  </rule>
  <rule name=”group_group”>
   <match url=”^(.*/)*group-([0-9]+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/forum.php\?mod=group&fid={R:2}&page={R:3}&{R:4}”
/>
  </rule>
  <rule name=”home_space”>
   <match url=”^(.*/)*space-(username|uid)-(.+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/home.php\?mod=space&{R:2}={R:3}&{R:4}” />
  </rule>
  <rule name=”home_blog”>
   <match url=”^(.*/)*blog-([0-9]+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/home.php\?mod=space&uid={R:2}&do=blog&id={R:3}&{R:4}”
/>
  </rule>
  <rule name=”forum_archiver”>
   <match url=”^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$” />
   <action type=”Rewrite”
url=”{R:1}/index.php\?action={R:2}&value={R:3}&{R:4}” />
  </rule>
</rules>
</rewrite>
<!–dz2.5–>
<rewrite>
<rules>
  <rule name=”portal_topic”>
   <match url=”^(.*/)*topic-(.+).html\?*(.*)$” />
   <action type=”Rewrite”
url=”{R:1}/portal.php\?mod=topic&topic={R:2}&{R:3}” />
  </rule>
  <rule name=”portal_article”>
   <match
url=”^(.*/)*article-([0-9]+)-([0-9]+).html\?*(.*)$” />
   <action type=”Rewrite”
url=”{R:1}/portal.php\?mod=view&aid={R:2}&page={R:3}&{R:4}”
/>
  </rule>
  <rule name=”forum_forumdisplay”>
   <match url=”^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/forum.php\?mod=forumdisplay&fid={R:2}&page={R:3}&{R:4}”
/>
  </rule>
  <rule name=”forum_viewthread”>
   <match
url=”^(.*/)*thread-([0-9]+)-([10bet体育 ,0-9]+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/forum.php\?mod=viewthread&tid={R:2}&extra=page={R:4}&page={R:3}&{R:5}”
/>
  </rule>
  <rule name=”group_group”>
   <match url=”^(.*/)*group-([0-9]+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/forum.php\?mod=group&fid={R:2}&page={R:3}&{R:4}”
/>
  </rule>
  <rule name=”home_space”>
   <match url=”^(.*/)*space-(username|uid)-(.+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/home.php\?mod=space&{R:2}={R:3}&{R:4}” />
  </rule>
  <rule name=”home_blog”>
   <match url=”^(.*/)*blog-([0-9]+)-([0-9]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/home.php\?mod=space&uid={R:2}&do=blog&id={R:3}&{R:4}”
/>
  </rule>
  <rule name=”forum_archiver”>
   <match url=”^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$” />
   <action type=”Rewrite”
url=”{R:1}/index.php\?action={R:2}&value={R:3}&{R:4}” />
  </rule>
  <rule name=”plugin”>
   <match
url=”^(.*/)*([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+).html\?*(.*)$”
/>
   <action type=”Rewrite”
url=”{R:1}/plugin.php\?id={R:2}:{R:3}&{R:4}” />
  </rule>
</rules>
</rewrite>

7.5通过web.config设置伪静态规则方法
is7.5下常见程序通过web.config实现伪静态新建一个以web.config命名的文件内容为
?xml version=1.0 encoding=UT…

以前在IIS6上配置伪静态还是挺复杂的,IIS7之后使用了插件机制,这让我们做伪静态变得简单多了。

一、服务器需要安装:URL Rewrite 扩展

下载地址:

提示:虽然IIS7也可以使用以前在IIS6上那种老的方法来配置伪静态,但是我们不使用,因为那样的话就体现不出IIS7的优势了。

二、在 web.config 中配置伪静态规则

注意要点

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注