JesseJames
JesseJames

Reputation: 55

How to change structure of URL

Currently my URL for my posts is like domainName\posts\id.

How do I change this to domainName\id?

In my web.php I'm using resource.

Route::resource('posts', 'PostController');

Upvotes: 1

Views: 96

Answers (1)

Syed Abdur Rehman Kazmi
Syed Abdur Rehman Kazmi

Reputation: 1647

You can do it by using custom URLS for your post and get requests like this

Route::post('/{any}', 'PostController@postAnything');
Route::get('/{any}', 'PostController@getAnything');

Although this will not be a good practice because these are wild cards and will not let pass any of your requests below them.

Upvotes: 3

Related Questions