.htaccess 将条件htaccess重写为web.config

zf9nrax1  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(126)

我想了解下面的htaccess文件条件是如何为web.config翻译的:

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
sh7euo9m

sh7euo9m1#

您可以使用IIS URL重写模块自动转换htaccess条件,您可以找到解释here
以下是已转换的规则:

<rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?{R:1}" appendQueryString="true" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{THE_REQUEST}" pattern="^[A-Z]{3,}\s(.*)/index\.php" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="{C:1}" />
        </rule>
      </rules>
    </rewrite>

相关问题