[英]Convert Apache mod_rewrite file to IIS URL Rewrite
I don't have good knowledge about IIS, and I need to convert the following htaccess file to a web.config to enable URL rewrite under IIS. 我对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]
Thanks 谢谢
Your rules could be converted into IIS URL Rewrite Module rules as follows: 您的规则可以转换为IIS URL重写模块规则,如下所示:
<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>
See this answer for further reference. 请参阅此答案以获取更多参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.