Joomla在IIS7通过Web.config配置实现URL Rewrite

Joomla生成的各个页面默认使用带查询参数的URL。在Apache中可以通过.htaccess文件配置URL重写,在IIS6中需要ISAPI_Rewrite或者Ionics ISAPI Rewrite Filter之类的插件实现URL重写,而在IIS7中可以通过安装Microsoft URL Rewrite Module for IIS 7实现。以下是IIS7中Joomla通过URL Rewrite实现搜索引擎友好地址的方法。1、下载并安装Microsoft URL Rewrite Module for IIS 7(好多虚拟主机提供商默认已经安装了,比如GoDaddy.com)。2、在Joomla安装目录中创建文件名为Web.config的文件。3、在Web.config文件中粘贴以下内容并保存:
<?xml version=”1.0″ encoding=”UTF-8″?><configuration>  <system.webServer>    <rewrite>      <rules>        <rule name=”Security Rule” stopProcessing=”true”>          <match url=”^(.*)$” ignoreCase=”false” />          <conditions logicalGrouping=”MatchAny”>            <add input=”{QUERY_STRING}” pattern=”mosConfig_[a-zA-Z_]{1,21}(=|\%3D)” ignoreCase=”false” />            <add input=”{QUERY_STRING}” pattern=”base64_encode.*\(.*\)” ignoreCase=”false” />            <add input=”{QUERY_STRING}” pattern=”(\&lt;|%3C).*script.*(\>|%3E)” />            <add input=”{QUERY_STRING}” pattern=”GLOBALS(=|\[|\%[0-9A-Z]{0,2})” ignoreCase=”false” />            <add input=”{QUERY_STRING}” pattern=”_REQUEST(=|\[|\%[0-9A-Z]{0,2})” ignoreCase=”false” [...]

Discuz在IIS7中通过Web.config实现URL Rewrite

把以下代码复制到网站目录中的配置文件web.config中的 <system.webServer>之后就可以了。
        <rewrite>            <rules>                <rule name=”Imported Rule 1″>                    <match url=”^archiver/((fid|tid)-[\w\-]+\.html)$” ignoreCase=”false” />                    <action type=”Rewrite” url=”archiver/index.php?{R:1}” appendQueryString=”false” />                </rule>                <rule name=”Imported Rule 2″>                    <match url=”^forum-([0-9]+)-([0-9]+)\.html$” ignoreCase=”false” />                    <action type=”Rewrite” url=”forumdisplay.php?fid={R:1}&page={R:2}” appendQueryString=”false” />                </rule>                <rule name=”Imported Rule 3″>                    <match url=”^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$” ignoreCase=”false” />                    <action type=”Rewrite” url=”viewthread.php?tid={R:1}&extra=page\%3D{R:3}&page={R:2}” appendQueryString=”false” />                </rule>                <rule name=”Imported Rule 4″>                    <match url=”^space-(username|uid)-(.+)\.html$” ignoreCase=”false” />                    <action type=”Rewrite” url=”space.php?{R:1}={R:2}” appendQueryString=”false” />                </rule>                <rule name=”Imported Rule 5″>                    <match url=”^tag-(.+)\.html$” ignoreCase=”false” />                    <action type=”Rewrite” url=”tag.php?name={R:1}” appendQueryString=”false” />                </rule>            </rules>        </rewrite>