Y
Y
Yaroslav2020-06-22 00:56:12
Laravel
Yaroslav, 2020-06-22 00:56:12

When following a route with required parameters in curly braces, laravel issues 404 | page not found. What is the problem?

Project in OpenServer on laravel6, everything works fine. Uploaded all the files to the hosting, using simple routes (eg:
{{ route('example') }} ) everything goes as it should. But it's worth trying to follow a route with required parameters (eg: {{route(' example', $item)}} ) the server gives a 404 Not Found error, but the URL in the address bar shows that the variable has arrived.

Pass:
{{ route(' example', $item) }}
Accept:
Route::get('/page/{item}', '[email protected]');
We get:
in the address bar
https://www.website.ru/page/item
on the page itself
404 Not Found

I've gone through everything I could. As I understand it, the problem is in the htaccess file, but I can’t find how to configure it for my problem. And in general, how many htaccess files should be in the project? I did not touch them, and there is only one file in the public folder. And many write that there should be two, also in the root folder. Please help me figure it out.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yaroslav, 2020-06-23
@ManMadeMind

Everything turned out to be painfully simple and banal. I wrote the answer in my question.
The combat server does not work with Cyrillic in dynamic routes.
Routes on the local server

Route::get('/page/{item}', '[email protected]');
Route::get('/страница/{item}', '[email protected]');

they will work the same way, that is, they will work at all. But on a combat vehicle, the Cyrillic alphabet in the url will give 404|page not found. After "Latinization" all dynamic url's worked perfectly. But what is strange in this situation, static Cyrillic
Route::get('/страница/что_то_любое_но_не_динамически_подставляемое', '[email protected]');

works on the production server as well. Thank you all for your input, advice and willingness to help.

B
Bone, 2020-06-22
@Bone

I would try to start by replacing '[email protected]' with

Route::get('/page/{item}', function ($item) {
  return $item;
});

If this works, then the problem is in the path to the [email protected]

A
Anton Anton, 2020-06-22
@Fragster

If the parameter in the controller is a model, then when following the route, an attempt will be made to search by the primary key or the resolveRouteBinding method of the model will be executed if available. And if the object is not found, then there will be just a 404 error. https://laravel.com/docs/7.x/routing#route-model-b...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question