iis7.5下常见程序通过web.config实现伪静态

新建一个以web.config命名的文件内容为
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
<!--将下面的规则添加到这里-->

    </system.webServer> 
</configuration>

规则示例,选择需要的规则添加:
<!--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="true" />
                </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&amp;topic={R:2}&amp;{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&amp;aid={R:2}&amp;page={R:3}&amp;{R:4}" />
  </rule>
  <rule name="forum_forumdisplay">
   <match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&amp;fid={R:2}&amp;page={R:3}&amp;{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&amp;tid={R:2}&amp;extra=page%3D{R:4}&amp;page={R:3}&amp;{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&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}" />
  </rule>
  <rule name="home_space">
   <match url="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/home.php\?mod=space&amp;{R:2}={R:3}&amp;{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&amp;uid={R:2}&amp;do=blog&amp;id={R:3}&amp;{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}&amp;value={R:3}&amp;{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&amp;topic={R:2}&amp;{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&amp;aid={R:2}&amp;page={R:3}&amp;{R:4}" />
  </rule>
  <rule name="forum_forumdisplay">
   <match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&amp;fid={R:2}&amp;page={R:3}&amp;{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&amp;tid={R:2}&amp;extra=page%3D{R:4}&amp;page={R:3}&amp;{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&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}" />
  </rule>
  <rule name="home_space">
   <match url="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/home.php\?mod=space&amp;{R:2}={R:3}&amp;{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&amp;uid={R:2}&amp;do=blog&amp;id={R:3}&amp;{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}&amp;value={R:3}&amp;{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}&amp;{R:4}" />
  </rule>
 </rules>
</rewrite>

<!--dz3.0-->
<rewrite>
 <rules>
  <rule name="portal_topic">
   <match url="^(.*/)*topic-(.+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/portal.php\?mod=topic&amp;topic={R:2}&amp;{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&amp;aid={R:2}&amp;page={R:3}&amp;{R:4}" />
  </rule>
  <rule name="forum_forumdisplay">
   <match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&amp;fid={R:2}&amp;page={R:3}&amp;{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&amp;tid={R:2}&amp;extra=page%3D{R:4}&amp;page={R:3}&amp;{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&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}" />
  </rule>
  <rule name="home_space">
   <match url="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/home.php\?mod=space&amp;{R:2}={R:3}&amp;{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&amp;uid={R:2}&amp;do=blog&amp;id={R:3}&amp;{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}&amp;value={R:3}&amp;{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}&amp;{R:4}" />
  </rule>
 </rules>
</rewrite>


 


编辑:西部数码
日期:2012-08-21

收藏 】 【 打印 】   
您可对文档进行评分哟~

勾选遇到的问题提交给我们,收到反馈后保证及时修正更新!

提交反馈需要先登陆会员帐号

上一篇:会员账号所有人变更
下一篇:在IIS7下使用ASP连接ACCESS数据库时提示如下错误的处理方法
若文档内容对您没有帮助,不能解决问题? 您还可以 咨询在线客服提交工单搜索常见问题 ,我们将竭诚为您服务。
  >> 相关文章
 
分享至:
Top

24小时客服热线

400-651-5660

  • 售前咨询请拨4
  • 售后服务请拨5
  • 技术支持请拨7
  • 投诉建议请拨9
  • 备案问题请提交工单

咨询售后问题请先打开 电话助手