Home » Php » php – Add url extensions to Laravel routes

php – Add url extensions to Laravel routes

Posted by: admin July 12, 2020 Leave a comment


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


and another page with a different extension


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

How to&Answers:

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


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.


Route::get('{id}-{another_id}.html', '[email protected]')
        ->where('id', '.*?')
        ->where('another_id', '\d+');

Something like this