繁体   English   中英

如何将.htaccess代码转换为web.config?

[英]How can I convert .htaccess code to web.config?

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]

当您说转换为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>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM