php – IIS服务器,如何为Laravel 5配置url重写?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – IIS服务器,如何为Laravel 5配置url重写?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2172字,纯文字阅读大概需要4分钟。
内容图文
![php – IIS服务器,如何为Laravel 5配置url重写?](/upload/InfoBanner/zyjiaocheng/774/5aa22e3cd05e4fa69da42874c4365a3b.jpg)
目前,Uni只提供了一个IIS服务器来托管我们的php网站,我们想要使用Laravel框架,它确实在主页上工作.但不是任何其他控制器.
我的公用文件夹中的当前web.config是,
<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>
我的路线是,
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
我不太了解IIS,所以你有任何想法来配置它以使其工作吗?
附:
我们无权在阵营中配置IIS服务器,我们有权做的是上传web.config.
提前致谢.
解决方法:
最后我解决了这个问题,这不是一个完美的方式,但它确实奏效了.
<rule name="rewrite all requests to index.php" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
<rule name="Redirect / to index.php" stopProcessing="true">
<match url="^" ignoreCase="false" />
<action type="Rewrite" redirectType="Permanent" url="index.php" />
</rule>
正如我在开始时提到的,它不是一个完美的解决方案,它将所有URL重写为index.php,所以URL不漂亮,就像,
> a.com/login – > a.com/index.php/login
> a.com/ – > a.com/index.php
> a.com/login/index.php – > 404
因为我对IIS配置/重写不是很熟悉,所以必须有一些更好的解决方案,所以改进这行配置文件的建议会很棒.
无论如何,它在您无权设置IIS服务器的情况下工作.
它应该使Laravel项目在任何IIS服务器上运行,而无需更改服务器的设置.
参考文献
> IIS rewrite and asp.net route
> redirect all to one page
内容总结
以上是互联网集市为您收集整理的php – IIS服务器,如何为Laravel 5配置url重写?全部内容,希望文章能够帮你解决php – IIS服务器,如何为Laravel 5配置url重写?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。