I hope you are well. I have a site under Laravel using the OVH could web. I connect in FTP in order to update a file (the web.php file, it allows to define the routes of the site). I had put a middleware on some routes but I removed them in ftp. I return to my site but it still asks me to log in. So I tried it locally and this change works fine.
I'm using the Breeze framework.
Here is an example of what I had in route.php :
Route::group(['prefix' => 'test', 'middleware' => 'auth'], function(){
So I removed the 2nd part, which gives:
Route::group(['prefix' => 'test'], function(){
But it still doesn't work. Do you know if there is another place where I could indicate that an authentication is required in order to go to the page please?
Cordially
Yep, it's another Laravel route not found issue! This is actually quite an odd one. I am aware there are multiple issues here with the same error message at least, but none that seem to be the same as mine.
I am using the nWidart/laravel-modules (https://github.com/nWidart/laravel-modules) package for Laravel to create a module-based setup. I began with a fresh install of Laravel 5.4 via Composer, then generated the basic user authentication via php artisan make:auth. After basic setup, my app/Http/routes.php file looks like this:
// home page
Route::get('/', function () {
return view('welcome');
});
// login, logout, register, etc.
Route::auth();
// admin dashboard
Route::get('/admin', 'AdminController#index');
I then installed the modules package via Composer and ran php artisan module:make Finances Jobs Etsy to create three modules, Finances, Jobs, and Etsy. This ran without incident. I then went into the Http/routes.php file for each individual module and added the auth middleware and an additional prefix to each route group:
// Finances routes file
Route::group(['middleware' => ['web', 'auth'], 'prefix' => 'admin/finances', 'namespace' => 'Modules\Finances\Http\Controllers'], function()
{
Route::get('/', 'FinancesController#index');
});
// Jobs routes file
Route::group(['middleware' => ['web', 'auth'], 'prefix' => 'admin/jobs', 'namespace' => 'Modules\Jobs\Http\Controllers'], function()
{
Route::get('/', 'JobsController#index');
});
// Etsy routes file
Route::group(['middleware' => ['web', 'auth'], 'prefix' => 'admin/etsy', 'namespace' => 'Modules\Etsy\Http\Controllers'], function()
{
Route::get('/', 'EtsyController#index');
});
Now here is the very frustrating issue: all the base app routes work fine. The home page route, the auth routes, and the /admin route all work perfectly. In addition, all the Jobs module routes work perfectly as well. However, any and all routes from the Finances and Etsy modules do not work. Trying to access https://[site url]/admin/finances shows me the following error:
NotFoundHttpException in RouteCollection.php line 161:
Which to me says, Laravel can't find the given route, despite being able to find the route for the Jobs module.
Extra confusingly, it sort of seems like Laravel can find the routes, as running php artisan route:list DOES show me the routes for the Finances and Etsy modules.
I have also tried running php artisan cache:clear and php artisan route:clear multiple times, in case it was some sort of caching issue. No luck.
So at this point I have absolutely no idea what to make of all this. I've got three modules, one whose routes are working perfectly, and two others, whose identically-configured routes are not working at all, yet are being found by route:list. I'm pretty much out of ideas as to what the issue could be at this point.
UPDATE: interestingly, if I place the route in the base app routes.php file like so:
Route::group(['middleware' => ['web', 'auth'], 'prefix' => 'admin/finances'], function()
{
Route::get('/', '\Modules\Finances\Http\Controllers\FinancesController#index');
});
Then the route does work. So it seems to be an issue where the web application specifically can't seem to find the routes.php files for those two modules, but the console application can.
I has the same issue, I solved it adding name property in:
Module/[ModuleName]/Http/routes.php,
For example:
Route::get('alias','controller#functionName')->name('module.alias');
I hope this tip could help you!
I had the same error and it solved like this.
Change file modules.php :
'scan' => [
'enabled' => false,
'paths' => [
base_path('vendor/*/*'),
],
],
To this:
'scan' => [
'enabled' => true,
'paths' => [
base_path('modules/*'),
],
],
And then run:
php artisan route:clear
php artisan optimize
Recently,I just installed a chat package called Easychat. At first, it worked perfectly. I don't why but today I'm facing a problem where It said as in the pic
In the console it also said: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
The weirdest thing is that when I go to Route file and change the URI from easychat to something different like easychat222 just for testing.
From
Route::get('/easychat', [
'as' => 'chatnow',
'uses' => 'EasychatController#getIndex'
]);
To
Route::get('/easychat222', [
'as' => 'chatnow',
'uses' => 'EasychatController#getIndex'
]);
and refresh the page. It works perfectly with the old uri (easychat) not with the new one.
Anybody knows what is the problem here and please tell me how to fix it.
Thank you very much!
You're using wrong web server configuration. You should point web server to a public directory inside Laravel directory and restart it.
Change these lines in Apache config file (if you're using Apache):
For Apache you can use these directives:
DocumentRoot "/path_to_aravel_project/public"
<Directory "/path_to_aravel_project/public">
For nginx:
root /path_to_aravel_project/public;
I'm just about to host my laravel application. I use subdomains with wildcards. However I can somehow not access my auth and register views even though it works locally.
Route
Route::group(['domain' => '{slug}.mypage.de'], function()
{
Route::controllers([
'auth' => 'Auth\AuthControllerClient'
]);
...
I have the same route without the subdomain group where it works...
I have a problem when I use routes in Laravel 5.0, I only need to call this route:
Route::get('home', 'HomeController#index');
But the browser shows me this, when I write http://localhost/course/public/home:
Not Found
The requested URL /course/public/home was not found on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80
If I write http://localhost/course/public/
the index works but the other routes doesn't work, I don't know why.
In my Routes.php I have this:
Route::get('/', 'WelcomeController#index');
Route::get('home', 'HomeController#index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
I only downloaded laravel 5.0 with composer, I did not change nothing in the code after the download, I only want to test the routes and these don't work.
Thaks for your help.
in conclusion (the comments solved the problem, so thank you guys for this!!) you probably run Laravel on Apache and you don't have mod_rewrite enabled... or not configured correctly.
Laravel works with so called pretty urls. In order to achieve this, every request is rewritten and the config you can find in the .htaccess file in the public folder. This to give a quick and dirty explanation will let you write URLs without the index.php.
Additionally your server should serve the public folder and not the main folder. That's a security thing if you want to use your site in production.
Alternatively you can use nginx which in my opinion is a lot easier to configure and if you run laravel homestead everything comes straight out of the box.