在Laravel 4中在网址后附加斜杠 [英] Append trailing slash to url in Laravel 4
本文介绍了在Laravel 4中在网址后附加斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个简单的问题,但找不到有效的答案:
Simple question, but I can't find any answer that works:
如何在Laravel 4中的网址后面添加斜杠?
How to append trailing slash to url in Laravel 4?
推荐答案
如timgws所述,该解决方案不再适用于Laravel 4.1 +
As timgws mentioned, this solution no longer works in Laravel 4.1+
如果您在bootstrap/start.php中注释掉第16行
If you comment out line 16 in bootstrap/start.php
https://github.com/laravel/laravel/blob/master/bootstrap/start.php#L16
//$app->redirectIfTrailingSlash();
它不应再重定向到没有斜杠的URL.
It should no longer redirect to the URL without the slash.
然后,您可以重做路线以显示斜线,例如:
Then you can redo your route to show the trailing slash like:
Route::get('login/', function() { // etc
这篇关于在Laravel 4中在网址后附加斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文