In my case, I have installed Laravel 10 in UBUNTU, after installation, I created front and admin routes, but there is a problem with routes, the front route is working, but the admin route is not working, when I call the admin route it says,
Not Found
The requested URL was not found on this server.
Apache/2.4.41 (Ubuntu) Server at localhost Port 80
php8.1 artisan --version
Laravel Framework 10.15.0
php8.1 -v
PHP 8.1.21 (cli) (built: Jul 8 2023 07:09:57)
(NTS) Copyright (c) The PHP Group Zend Engine v4.1.21,
Copyright (c) Zend Technologies with Zend OPcache v8.1.21,
Copyright (c), by Zend Technologies
Routes
Route::get('/', [App\Http\Controllers\front\HomePageController::class,'index'])->name('home.index');
Route::get('/dashboard', [App\Http\Controllers\admin\DashboardController::class,'index'])->name('dashboard');
Controllers /var/www/html/laravel10/app/Http/Controllers/front/HomePageController.php
<?php
namespace App\Http\Controllers\front;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;
class HomePageController extends Controller
{
public function index()
{
return view('front.index');
}
}
?>
/var/www/html/laravel10/app/Http/Controllers/admin/DashboardController.php
<?php
namespace App\Http\Controllers\admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;
class DashboardController extends Controller
{
public function index()
{
return view('admin.index');
}
}
?>
Views /var/www/html/laravel10/resources/views/front/index.blade.php
<?php
echo "Front";
?>
/var/www/html/laravel10/resources/views/admin/index.blade.php
<?php
echo "Admin";
?>
everything is perfect front URL is working fine, https://localhost/laravel10/public
but the admin URL is not working https://localhost/laravel10/public/dashboard
when I comment front route and run the admin route(in admin route I remove /dashboard ) its works like below
/* Route::get('/', [App\Http\Controllers\front\HomePageController::class,'index'])->name('home.index'); */
Route::get('/', [App\Http\Controllers\admin\DashboardController::class,'index'])->name('dashboard');
/var/www/html/laravel10/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I don't understand what is happening here, I also checked in Laravel Log, and there is no error, even I checked in the apache2 log, also there is no error, I also checked the Folder permission, and all permission are correct,
please help me with this
Thanks.