【问题标题】:Apache mod_rewrite in IISIIS 中的 Apache mod_rewrite
【发布时间】:2019-06-15 21:56:24
【问题描述】:

在 IIS 服务器中安装 Laravel 5.7,Apache 的 mod-rewrite 规则对 IIS 的等价物是什么?

IIS 内置的自动转换器在其转换工具上抛出错误。

APACHE 规则

Options +FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

IIS 错误

<rewrite>
  <rules>
    <!--The rule cannot be converted into an equivalent IIS format because of unsupported flags: E-->
    <rule name="Imported Rule 2" stopProcessing="true">
      <match url="^" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php" />
    </rule>
  </rules>
</rewrite>

提前致谢。 最好的问候,

维克多·巴纳

【问题讨论】:

  • 我建议你可以参考下面的 web.config 来了解如何在 IIS 中运行 Laravel。 github.com/laravel/laravel/blob/master/public/web.config
  • 我猜这最终是一个配置问题。如果您不熟悉 IIS(我假设这是基于被询问的方式),我可以给出的最佳建议是您联系负责 IIS 的系统管理员。如果您也不熟悉 Apache 并且您的新系统管理员也不熟悉,您需要将您的新旧系统管理员聚集在一起,以便他们可以在两个 Web 服务器之间转换配置。 This is documented
  • 最终的解决方案是编辑 web.config 文件。非常感谢你的帮助!如果我有权限,我会将您的答案标记为解决方案:)

标签: laravel apache iis mod-rewrite


【解决方案1】:

最终的解决方案是编辑 web.config 文件。

在这种情况下,对于 Laravel 5.7 和 IIS,其值为:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-15
    • 2014-12-18
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多