使用IIS 10安装laravel 5.4
答
这就是我做的,我不知道这是正确的方式。
- 安装URL重写模块(https://www.iis.net/downloads/microsoft/url-rewrite)
- 在某个文件夹e将回购:/网站/ HelloWorld的
- 在IIS添加一个名为 “HelloWorld” 的指向E中的虚拟目录:/网站/的HelloWorld /公
- 确保文件夹引导程序/缓存和存储处于写入状态。
- 不要忘记制作env文件。
-
在你web.php路由文件提出:
路线::得到( '/',函数(){ 回报视图( '欢迎'); });
Route :: get('/ also',function(){ return view('welcome'); });
添加文件web.config中公开目录,并贴个规则:
<?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>
</configuration>
您现在应该能够访问这两个URL意味着laravel路由按预期工作。如果你尝试另一条不存在的路线,你会得到一个laravel exeption。