Now,/post/always jumps to the other page instead of jumping to the/post location.
My Laravel version is 4.2, and here is the test code.
php
Route::get('post', function() { return 'w/out slash'; });Route::get('post/', function() { return 'with slash'; });
php
Route::get('post/', function() { return 'with slash'; });Route::get('post', function() { return 'w/out slash'; });
The above two configurations, the results are as follows, are/post/301 jump to another page,/post page normal.
curl http://localhost/gitcafe/public/postwith slashcurl http://localhost/gitcafe/public/post/301 Moved PermanentlyMoved Permanently
The document has moved here.
Reply content:
Now,/post/always jumps to the other page instead of jumping to the/post location.
My Laravel version is 4.2, and here is the test code.
php
Route::get('post', function() { return 'w/out slash'; });Route::get('post/', function() { return 'with slash'; });
php
Route::get('post/', function() { return 'with slash'; });Route::get('post', function() { return 'w/out slash'; });
The above two configurations, the results are as follows, are/post/301 jump to another page,/post page normal.
curl http://localhost/gitcafe/public/postwith slashcurl http://localhost/gitcafe/public/post/301 Moved PermanentlyMoved Permanently
The document has moved here.
Http://stackoverflow.com/questions/22063520/laravel-slash-after-url-re ...
Will it? Route
the behavior of the L5 component I remember is:
- Whether with the trailing slash or not, are considered the same route;
- 301 with Slash to jump to without slash (at least
GET
so);
- When the same route is specified two times, the back of the overlay precedes it.
Here are the test cases and results:
Case 1
$ diff my_l5_app/app/Http/routes.php l5_fresh/app/Http/routes.php22,24d21<< Route::get('post/', function() { return 'with slash'; });< Route::get('post', function() { return 'w/out slash'; });$ curl http://test1.l5.invalid/post/这里Web server提示了301跳转到 http://test1.l5.invalid/postSF的前台渲染有误,结果见 http://pastebin.com/ZMh0smvq$ curl http://test1.l5.invalid/postw/out slash
Case 2
$ diff my_l5_app/app/Http/routes.php l5_fresh/app/Http/routes.php22,24d21<< Route::get('post', function() { return 'w/out slash'; });< Route::get('post/', function() { return 'with slash'; });$ curl http://test1.l5.invalid/post/这里Web server提示了301跳转到 http://test1.l5.invalid/postSF的前台渲染有误,结果见 http://pastebin.com/ZMh0smvq$ curl http://test1.l5.invalid/postwith slash
Because/post/and/post are two routing paths, to point them to a location, assign the configuration to both of them, pointing to the same location.
Laravel don't know, but I'm all over the other route.
/post/?