The public directory has a books directory, I also have Route::get('books', 'BooksController@index'); Before the catalog appeared, everything worked fine. After that, a directory with a 403 error began to open and the full path localhost / myapp / public / books was displayed in the address bar. How to solve this problem?
1 answer
The simplest solution is to rename a route or directory, even a directory is better. More difficult - depends on the purpose and situation. I will give 2 options.
In the route file, check the URL for is_dir (), and register the route with a different URL and use the naming as.
If (is_dir ($ books_path)) {Route :: get ("knigi", ["as" => "books", "uses" => Controller :: class. "@ Action"]); } else {Route :: get ("books", ["as" => "books", "uses" => Controller :: class. "@ action"]); }
In the controller action do a check on the existence of this file. And to help write the helper function. The general logic is as follows: checking with a helper there exists such a file using url books / bulgakov-master-imargarita.jpg if it is true, the method returns the file itself for viewing, if not, the view and common logic.
I don’t see any more variations)) I hope I helped))
UPD sorry, I misread the question))) but the bottom line is just the opposite.)) However, you will have a problem with viewing from this directory. Will have extra. The parameter in the request to send, which will determine - route to view or file.