Answer the question
In order to leave comments, you need to log in
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
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]');
Route::get('/страница/что_то_любое_но_не_динамически_подставляемое', '[email protected]');
I would try to start by replacing '[email protected]' with
Route::get('/page/{item}', function ($item) {
return $item;
});
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 questionAsk a Question
731 491 924 answers to any question