Nith Srey
Nith Srey

Reputation: 11

How to change laravel 5.4 permalink pattern?

I was tasked to convert a website from an existing framework to Laravel. However, I meet with difficulty when dealing with permalink.

I want to keep the original pattern of the permalink from the old framework because the old permalink had been used a lot in Facebook posts. So if I change it, the old posts with the old links will not work anymore.

This is the old permalink pattern:

domain.com/article?id=123

However, the routing for laravel is like this:

domain.com/article/123

So, how do i change the route in laravel?

Example:

Route::get('/article/{post}', 'PostsController@show');

to

Route::get('/article?id={post}', 'PostsController@show');

Upvotes: 1

Views: 467

Answers (1)

kerrin
kerrin

Reputation: 3452

An option would be to develop the new app with Laravel and out-of-the-box links. This would make ongoing maintenance and upgrades less likely to break things.

Then, set up a series of 301 redirects in your .htaccess file to manage the redirections from Facebook, etc.

Upvotes: 0

Related Questions