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

dev_kassimi's avatar

Help on laravel routes

Hi guys,

How I can create URLs like this using routes

example.com/Jfd9eJFg36 <== I want my download page to be like this

But I don't want to get problems with the other routes like :

example.com/login
example.com/register
example.com/contact
0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

You can define a catch-all route at the end of your routes file so that any hard-coded routes are matched first:

// every other route

Route::get('{hash}', fn ($hash) {
	// logic to find file using $hash or abort with `404`

	return response()->download() //etc.
})

Please or to participate in this conversation.