Would you like to learn how to redirect the 404 error to a specific URL on the Nginx server? In this tutorial, we are going to configure the Nginx server to redirect the 404 error to a specific page.
• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Nginx 1.18.0
In our example, the Nginx server is hosting the website WWW.GAMEKING.TIPS
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Nginx – Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Nginx.
Tutorial Nginx – Redirect the error 404 to a page
Install the Nginx server.
Edit the Nginx configuration file for the default website.
Add the following line to the configuration file.
Here is the file, before our configuration.
Here is the file, after our configuration.
Restart the Nginx service.
In our example, the Nginx server will redirect the 404 errors to a specific URL.
From a remote Linux computer, try to access a page that does not exist.
Here is the command output.
In our example, the 404 error was redirected to a specific URL using a 302 code.
There are multiple ways to redirect an error page using Nginx.
Congratulations! You redirected the 404 errors on the Nginx server.