IIS7上的Laravel 5不适用于web.config [英] Laravel 5 on IIS7 does not work with web.config
问题描述
我有一个简单的Laravel 5应用程序.它是在Xampp上开发的,并且运行良好.我将其复制到生产服务器上,但它不起作用. web.config文件出了点问题,因为如果我删除它,则该应用程序可以与index.php/path完美配合
I have a simple Laravel 5 app. It was developed on Xampp, and worked perfectly. I copied it onto the production server, and it does not work. Something is wrong with the web.config file, because if I remove it, then the app works perfectly with index.php/path
我的webconfig如下:
My webconfig is as follows:
<?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>
该应用程序位于网站的子文件夹中,我无法创建新网站,但可以根据需要重新启动IIS.我真的不太了解IIS(实际上我很讨厌IIS),所以我不知道在哪里检查,但是由于该应用程序在没有web.config的情况下可以正常工作,因此我认为它一定是罪魁祸首.
The app is located at a subfolder of the website and I cannot create a new site, but I can restart IIS as needed. I really don't know IIS very well (in fact I hate it), so I don't know where to check, but since the app works without the web.config, I assume it must be the culprit.
推荐答案
IIS必须具有URL Rewrite Module
才能使Laravel web.config
正常工作.
IIS Needs to have the URL Rewrite Module
for the Laravel web.config
to work.
在XAMPP上,它将立即可用,因为其中包含Apache mod_rewrite
模块,并且XAMPP已经提供了大多数配置设置.
On XAMPP, it will work out of the box as the Apache mod_rewrite
module is included and most of the configuration settings are already provided by XAMPP.
Microsoft URL重写. 从此处
Microsoft URL Rewrite. Download it from here
这篇关于IIS7上的Laravel 5不适用于web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!