How to fix Laravel 404 and 403 error when using VPS Directadmin running Nginx - HOSTVN Blog

Fix Laravel 404 and 403 - Laravel is a free and open source PHP framework that aims to support the development of web applications under the MVC Model-View-Controller structure. When you deploy Laravel on VPS using Directadmin with Nginx webserver, you may encounter 404 and 403 errors when accessing the website. In this article, we will show you how to fix this error.

  • To own Cloud VPS SSD with Directadmin, you can refer to the HOSTVN Cloud VPS SSD packages that are provided here

Cause of error

Note: In this article we will only guide errors due to the virtual hosting, chmod configuration and the default that your code is completely normal without errors due to routes and auth.

According to Laravel's structure, all requests will go straight to the public directory, but the virtual hosting configuration of VPS will only point to the directory. public_html, this is the cause of 403 errors when implementing Laravel source code.

For 404 errors, the main reason is that Nginx differs from Apache, it does not use the .htaccess file, so when deploying Laravel on Nginx will lack the rewrite rules that lead to 404 errors.

How to fix Laravel 404 and 403 errors when using VPS Directadmin running Nginx

The first thing to do is to check and revise the vhost file properly, to do this you log into Directadmin with your account. admin And follow the steps below:

Step 1: From the admin interface, you access Custom HTTPD Configurations


Step 2: Click on the domain you want to edit vhost

Custom HTTPD Configurations

Step 3: Add the following content to

  • The first box you add the following content

Inside: hostvn is the user, is your domain name instead of your user and domain name. To be exact, you can copy the path at the bottom to paste and add / public for accuracy

nginx.conf file

  • UMBRELLA CUSTOM3 You add the following content

After adding you press the button Save to save

nginx.conf Customization - fix Laravel 404 error

Step 4: Restart Nginx

To finish you will need to restart Nginx, you log into the VPS via SSH and run the command:

If you do not know how to use SSH, you can refer to the following article: Instructions for using PuTTY to SSH into VPS


Through this article, we have shown you how to fix Laravel 404 and 403 errors when deploying on VPS Directadmin using Nginx webserver. If you have any contributions you can leave a comment below.

In addition, you can also refer to other shared articles of HOSTVN here