我对IIS没有很好的了解,我需要将以下htaccess文件转换为web.config,以便在IIS下启用URL重写。
RewriteEngine On
RewriteRule ^index.html$ index.php [L]
RewriteRule ^/?([0-9a-zA-Z_-]+)/?$ rewrite.php?param1=$1 [L]
RewriteRule ^/?([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/?$ rewrite.php?param1=$1¶m2=$2 [L]
RewriteRule ^/?([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/([^/]+)/?$ rewrite.php?param1=$1¶m2=$2¶m3=$3 [L]
由于
答案 0 :(得分:0)
您的规则可以转换为IIS 网址重写模块规则,如下所示:
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^index.html$" ignoreCase="false" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^([0-9a-zA-Z_-]+)/?$" ignoreCase="false" />
<action type="Rewrite" url="rewrite.php?param1={R:1}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/?$" ignoreCase="false" />
<action type="Rewrite" url="rewrite.php?param1={R:1}&param2={R:2}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 4" stopProcessing="true">
<match url="^([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/([^/]+)/?$" ignoreCase="false" />
<action type="Rewrite" url="rewrite.php?param1={R:1}&param2={R:2}&param3={R:3}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
有关详细信息,请参阅this answer。