Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Cryank's avatar

route parameters with "/"

Hello everyone,

I have a problem about routing

First of all, routes.php

Route::resource('user,'UserController');

url
user/{slug}/edit/

normally it works fine but if slug contains "/" (e.g. abc/123) it will breaks the routing and causes page not found.

I did some search about this issue and I found one in StackOverFlow
http://stackoverflow.com/questions/21552604/how-to-define-a-laravel-route-with-a-parameter-that-contains-a-slash-character

What if i need to do if I define routes using "resource" to handle this problem and is it good to allow route parameters contains "/" ?
Thanks a lot

0 likes
3 replies
joedawson's avatar

Simple answer, don't put slashes in URLS. Use dashes instead maybe?

1 like
EliasSoares's avatar
Level 10

You can encode your slashes on url, so it will not cause any problem, although it will not be pretty anymore.

So I suggest you to replace the slash by a dash.

1 like
Cryank's avatar

Thanks all, seems replace slash by a dash would be better.

Please or to participate in this conversation.