0
RewriteEngine On
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?:www.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://%2%3 [R=301,L]
RewriteCond %{HTTP_Host} ([^.]+).itsprofile.com$ [NC]
RewriteRule (.*) http://itsprofile.com/viewindex.php$1?id =%1 [NC,L]
4

1 回答 1

1

当您说转换为 web.config 时,我假设您的意思是将 .htaccess 重写规则转换为 IIS URL 重写规则。您可以在此处找到有关将 .htaccess 规则导入 IIS URL 重写的信息。

您上面的重写规则将被导入并转换为:

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url=".?" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="(on)?" ignoreCase="false" />
        <add input="{HTTP_HOST}" pattern="^(?:www.)(.+)$" />
        <add input="{URL}" pattern="(.+)" ignoreCase="false" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="http(?{C:1}s)://{C:2}{C:3}" appendQueryString="false" />
    </rule>
    <rule name="Imported Rule 2">
      <match url="(.*)" ignoreCase="false" />
      <conditions>
        <add input="{HTTP_Host}" pattern="([^.]+).itsprofile.com$" />
      </conditions>
      <action type="Redirect" redirectType="Found" url="http://itsprofile.com/viewindex.php{R:1}?id" appendQueryString="false" />
    </rule>
  </rules>

自然,您会想要测试所有规则。

于 2012-10-12T04:17:03.303 回答