htaccess 不适用于 iis

2022-01-04 00:00:00 php iis .htaccess rewrite web-config

如何将 .htaccess 转换为 web.config.

how to convert .htaccess to web.config.

我才知道我需要使用 web.config 而不是 htaccess.请在下面找到我的 htaccess

I just come to know that I need to use web.config instead of htaccess. Please find my htaccess below

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

如何将其转换为 web.config ?

how i can convert it into web.config ?

推荐答案

将下面的代码复制粘贴到 web.config 中

copy paste below code in your web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <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>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

相关文章