1

谁能告诉我下面的重写对于 web.config 文件的转换是什么?

RewriteEngine On
RewriteRule ^/(credits|content)/?$ switch.php?view=$1

或者,如果有任何在线转换工具会很棒。

谢谢

编辑

例如:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

将会:

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^example\.com$" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}" />
    </rule>
  </rules>
</rewrite>
4

2 回答 2

1

我无法准确告诉您如何转换您提供的规则(不幸的是,我不擅长 .htaccess 或 web.config),但是 IIS 管理器中内置了一个方便的工具,可以让您转换 .htaccess 重写规则入 IIS URL 重写规则。

它的用法在这里描述:

http://www.iis.net/learn/extensions/url-rewrite-module/importing-apache-modrewrite-rules

于 2013-05-13T15:24:40.083 回答
0

这将转换 2 种传入 URL,如下所示:

http[s]://yoursite.com/credits => switch.php.view=credits
http[s]://yoursite.com/credits/ => switch.php.view=credits
http[s]://yoursite.com/content => switch.php.view=content
http[s]://yoursite.com/content/ => switch.php.view=content

注意:此规则不保留 URL 中的参数,例如:

http[s]://yoursite.com/credits?param1=aa&param2=bb => switch.php.view=credits
http[s]://yoursite.com/credits/?param1=aa&param2=bb => switch.php.view=credits
http[s]://yoursite.com/content?param1=aa&param2=bb => switch.php.view=content
http[s]://yoursite.com/content/?param1=aa&param2=bb => switch.php.view=content
于 2013-04-25T15:38:39.517 回答