How does the Laravel route write to implement/post and/post/point to a location?

Source: Internet
Author: User
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.

phpRoute::get('post', function() { return 'w/out slash'; });Route::get('post/', function() { return 'with slash'; });
phpRoute::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 Permanently

Moved 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.

phpRoute::get('post', function() { return 'w/out slash'; });Route::get('post/', function() { return 'with slash'; });
phpRoute::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 Permanently

Moved Permanently

The document has moved here.

Http://stackoverflow.com/questions/22063520/laravel-slash-after-url-re ...

Will it? Routethe behavior of the L5 component I remember is:

    1. Whether with the trailing slash or not, are considered the same route;
    2. 301 with Slash to jump to without slash (at least GET so);
    3. 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/?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.