程序如何实现将 .htaccess 规则文件内容转换为 web.config (win2008) 规则的文件

坤平 发布于 2014/12/30 17:51
阅读 1K+
收藏 0
# .htaccess文件
RewriteEngine On
RewriteBase /bbs
RewriteRule ^archiver/([a-z0-9-]+.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+).html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+).html$ space.php?$1=$2

RewriteRule ^tag-(.+).html$ tag.php?name=$1

自动转换为web.config规则文件:

<rule name="rule 1Z">

<match url="^bbs/archiver/([a-z0-9-]+.html)$"  />

<action type="Rewrite" url="/bbs/archiver/index.php?{R:1}"  />
</rule>
<rule name="rule 2Z">
<match url="^bbs/forum-([0-9]+)-([0-9]+).html$"  />
<action type="Rewrite" url="/bbs/forumdisplay.php?fid={R:1}&amp;page={R:2}"  />
</rule>
<rule name="rule 3Z">
<match url="^bbs/thread-([0-9]+)-([0-9]+)-([0-9]+).html$"  />
<action type="Rewrite" url="/bbs/viewthread.php?tid={R:1}&amp;extra=page\%3D{R:3}&amp;page={R:2}"  />
</rule>
<rule name="rule 4Z">
<match url="^bbs/space-(username|uid)-(.+).html$"  />
<action type="Rewrite" url="/bbs/space.php?{R:1}={R:2}"  />
</rule>
<rule name="rule 5Z">
<match url="^bbs/tag-(.+).html$"  />
<action type="Rewrite" url="/bbs/tag.php?name={R:1}"  />
</rule>


加载中
返回顶部
顶部