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]
答案 0 :(得分:1)
当你说转换为web.config时,我将假设你的意思是将.htaccess重写规则转换为IIS URL重写规则。您可以找到有关将.htaccess规则导入IIS URL重写here的信息。
上面的重写规则将被导入并转换为:
<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>
当然,您需要测试所有规则。