.htaccess 将规则转换重写为web.config
有谁能告诉我,对于一个web.config文件,下面的重写将如何转换.htaccess 将规则转换重写为web.config,.htaccess,mod-rewrite,redirect,web-config,.htaccess,Mod Rewrite,Redirect,Web Config,有谁能告诉我,对于一个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] 将是: <re
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>
这将转换两种传入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¶m2=bb => switch.php.view=credits
http[s]://yoursite.com/credits/?param1=aa¶m2=bb => switch.php.view=credits
http[s]://yoursite.com/content?param1=aa¶m2=bb => switch.php.view=content
http[s]://yoursite.com/content/?param1=aa¶m2=bb => switch.php.view=content
这将转换两种传入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¶m2=bb => switch.php.view=credits
http[s]://yoursite.com/credits/?param1=aa¶m2=bb => switch.php.view=credits
http[s]://yoursite.com/content?param1=aa¶m2=bb => switch.php.view=content
http[s]://yoursite.com/content/?param1=aa¶m2=bb => switch.php.view=content
我无法确切地告诉您如何转换您提供的规则(遗憾的是,我不太擅长.htaccess或web.config),但IIS管理器中内置了一个方便的工具,可以将.htaccess重写规则转换为IIS URL重写规则 其用法如下所述:
我无法确切地告诉您如何转换您提供的规则(遗憾的是,我不太擅长使用.htaccess或web.config),但IIS管理器中内置了一个方便的工具,可用于将.htaccess重写规则转换为IIS URL重写规则 其用法如下所述:
谢谢你的回答,但我还是有点困惑,我到底应该把这些放在哪里?我看到的例子看起来像我在问题中提供的编辑。谢谢你的回答,但我仍然有点困惑,我到底应该把这些例子放在哪里?我看到的例子看起来像我在问题中提供的编辑。