I got so many net::ERR_ABORTED 404 (Not Found) for my public/assets file when accessing the route of / but when I tried another route like /home with the same page and same file its works fine.
I deployed my Laravel 10 project on Ubuntu 22 with Nginx.
this is my Nginx virtual host configuration file :
root /var/www/v2-hexagon/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
server_name compro.hexagon.co.id www.compro.hexagon.co.id;
try_files $uri $uri/ /index.php?$query_string;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
location ~ /.(?!well-known).* {
<code>server {
listen 80;
root /var/www/v2-hexagon/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
server_name compro.hexagon.co.id www.compro.hexagon.co.id;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* {
deny all;
}
}
</code>
server {
listen 80;
root /var/www/v2-hexagon/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
server_name compro.hexagon.co.id www.compro.hexagon.co.id;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* {
deny all;
}
}
and this is my routes/web.php file :
use IlluminateSupportFacadesRoute;
Route::get('/', function () {
Route::get('/home', function () {
Route::get('/about', function () {
Route::get('/Portofolio', function () {
return view('Portofolio');
Route::get('/Services', function () {
Route::get('/News', function () {
Route::get('/Career', function () {
Route::get('/Contact', function () {
Route::get('/News/Post/{id}', function ($id) {
return view('singlepost', ['id' => $id]);
Route::get('/Portofolio/Post/{id}', function ($id) {
return view('singleporto', ['id' => $id]);
// Route::get('/about_layout', function () {
// return view('about_layout');
Route::get('/Service/IT Consultation', function () {
return view('IT Consultation');
})->name('IT Consultation');
Route::get('/Service/Digital Marketing', function () {
return view('Digital Marketing');
})->name('Digital Marketing');
Route::get('/Service/Branding', function () {
<code><?php
use IlluminateSupportFacadesRoute;
Route::get('/', function () {
return view('Home');
})->name('Home');
Route::get('/home', function () {
return view('Home');
})->name('Home');
Route::get('/about', function () {
return view('about');
})->name('About');
Route::get('/Portofolio', function () {
return view('Portofolio');
})->name('Portofolio');
Route::get('/Services', function () {
return view('Services');
})->name('Services');
Route::get('/News', function () {
return view('News');
})->name('News');
Route::get('/Career', function () {
return view('Career');
})->name('Career');
Route::get('/Contact', function () {
return view('Contact');
})->name('Contact');
Route::get('/News/Post/{id}', function ($id) {
return view('singlepost', ['id' => $id]);
})->name('singlepost');
Route::get('/Portofolio/Post/{id}', function ($id) {
return view('singleporto', ['id' => $id]);
})->name('singleporto');
// Route::get('/about_layout', function () {
// return view('about_layout');
// });
Route::get('/Service/IT Consultation', function () {
return view('IT Consultation');
})->name('IT Consultation');
Route::get('/Service/Digital Marketing', function () {
return view('Digital Marketing');
})->name('Digital Marketing');
Route::get('/Service/Branding', function () {
return view('Branding');
})->name('Branding');
</code>
<?php
use IlluminateSupportFacadesRoute;
Route::get('/', function () {
return view('Home');
})->name('Home');
Route::get('/home', function () {
return view('Home');
})->name('Home');
Route::get('/about', function () {
return view('about');
})->name('About');
Route::get('/Portofolio', function () {
return view('Portofolio');
})->name('Portofolio');
Route::get('/Services', function () {
return view('Services');
})->name('Services');
Route::get('/News', function () {
return view('News');
})->name('News');
Route::get('/Career', function () {
return view('Career');
})->name('Career');
Route::get('/Contact', function () {
return view('Contact');
})->name('Contact');
Route::get('/News/Post/{id}', function ($id) {
return view('singlepost', ['id' => $id]);
})->name('singlepost');
Route::get('/Portofolio/Post/{id}', function ($id) {
return view('singleporto', ['id' => $id]);
})->name('singleporto');
// Route::get('/about_layout', function () {
// return view('about_layout');
// });
Route::get('/Service/IT Consultation', function () {
return view('IT Consultation');
})->name('IT Consultation');
Route::get('/Service/Digital Marketing', function () {
return view('Digital Marketing');
})->name('Digital Marketing');
Route::get('/Service/Branding', function () {
return view('Branding');
})->name('Branding');
To be cleared, I got this kind of error only when accessing the route / but when I accessing the /home route with same function it works fine.
Any helps?