dongliu8542 2014-06-19 17:30
浏览 14
已采纳

漂亮的URL使用laravel 4.2

I'm creating a website using Laravel (first time user) and I have managed to have URL's such as

localhost/branch/pass

so without using the .php at the end of pass. But what I'm trying to achieve is this, when a user visits the 'pass' page they should take a token with them which is sent via email so they should visit it like this...

localhost/branch/pass?token=blah

what I want the URL to look like is...

localhost/branch/pass/blah

I've achieved this before in .htaccess while NOT using laravel I was just wondering if laravel had their own way of doing this or will it be the same as I've previously done?

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • dragon_9000 2014-06-19 17:36
    关注

    In your Routes file, we can filter for dynamic properties using {} in the path. Being that this is a GET request, we can just use Route::get.

    Route::get('branch/pass/{token}', 'MyController@MyFunction');
    

    Then you can properly make your URL's in the email like:

    http://localhost/branch/pass/blah
    

    and the blah which is your token, will be passed as an argument to the function you declared within your controller.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试