如何讓Laravel 5.3創建帶有斜線的路由URL?Laravel:我如何讓路線路線返回帶有斜線的路線?
路線被定義爲
Route::get('/home/', ['as' => 'home', 'uses' => '[email protected]']);
然後創建與在視圖中的路線輔助函數的網址:
{{ route('home') }}
這產生http://localhost:8000/home
代替http://localhost:8000/home/
。
此問題與Laravel - append a trailing slash in routes非常相似,但該問題也沒有答案,在我看來,我的描述更短。
編輯: 從文檔的兩種可能的命名方法不有所作爲:
Route::get('/home/', ['as' => 'home', 'uses' => '[email protected]']);
Route::get('/home/', '[email protected]')->name('home');
當你使用尾部斜線訪問它時會發生什麼? afaik它會重定向到別的地方。其解決方案之一是[這麼回答](http://stackoverflow.com/a/21735548/4648586) –
只要Web服務器不重定向laravel將響應請求。 – tback
它與['.htaccess'](https://github.com/laravel/laravel/blob/master/public/.htaccess#L10)有關。正如它在[這個問題](http://stackoverflow.com/questions/34441338/laravel-5-bad-behaviour-while-removing-trailing-slash)中討論的,你必須在公共目錄中編輯你的'.htaccess'。雖然... [在某些討論中](https://github.com/laravel/framework/issues/58#issuecomment-12367008) –