Add url extensions to Laravel routes

删除回忆录丶 提交于 2019-12-22 05:43:14

问题


Is it possible to add an extension to laravel routes like so?

http://www.mywebsite.com/members/login.html

and another page with a different extension

http://www.mywebsite.com/contactus.htm

I am transitioning an old website into laravel but the owner doesn't want to change the URL for SEO purposes.


回答1:


Yes, this is certainly possible and very straightforward to do with Laravel.

routes.php:

Route::get('members/login.html', function() { return View::make('members.login'); } );

Then you need to create the view members/login.php or members/login.blade.php in your views directory.




回答2:


Route::get('{id}-{another_id}.html', 'Controller@view')
        ->where('id', '.*?')
        ->where('another_id', '\d+');

Something like this



来源:https://stackoverflow.com/questions/22287649/add-url-extensions-to-laravel-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!