IIS7 上的 Laravel 5 无法使用 web.config

Moh*_*oha 1 windows iis laravel laravel-5

我有一个简单的 Laravel 5 应用程序。它是在 Xampp 上开发的,并且运行良好。我把它复制到生产服务器上,但它不起作用。web.config 文件有问题,因为如果我删除它,那么该应用程序可以与 index.php/path 完美配合

我的网络配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    <rewrite>
      <rules>
        <rule name="Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="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>
Run Code Online (Sandbox Code Playgroud)

该应用程序位于网站的子文件夹中,我无法创建新网站,但我可以根据需要重新启动 IIS。我真的不太了解 IIS(事实上我讨厌它),所以我不知道在哪里检查,但由于该应用程序在没有 web.config 的情况下工作,我认为它一定是罪魁祸首。

SiN*_*iTY 5

IIS 需要URL Rewrite ModuleLaravelweb.config才能工作。

在 XAMPP 上,它可以开箱即用,因为mod_rewrite包含 Apache 模块,并且 XAMPP 已经提供了大部分配置设置。

微软 URL 重写。从这里下载