laravel - IIS 中的 Apache mod_rewrite
问题描述
在 IIS 服务器中安装 Laravel 5.7,Apache 对 IIS 的 mod-rewrite 规则是什么?
IIS 内置自动转换器在其转换工具上引发错误。
阿帕奇规则
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 文件。
在这种情况下,对于 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>
推荐阅读
- wordpress - 从实时托管中进行一些自定义后提取 WordPress 主题。用途:用于重用主题
- sisense - 您可以在 Sisense 中使用 BLOX 将图像与文本叠加吗
- scala - 在 Spark DataFrame 的多个列上应用转换的优化方法
- nuxt.js - 如何使用 vue 路由器将道具传递到 nuxt 错误页面?
- linux - Vim :s 替换一行中出现的特定 N < g
- image - image.Decode 在 golang 嵌入上失败
- android-layout - Android Studio 中缺少工具栏?
- postgresql - Postgres 唯一索引有时会被忽略
- java - Java的HttpClient异步是如何实现的?
- mysql - 根据 Where 参数从 3 个不同的表中获取数据 - MySQL