How to Set Up 404 Redirects in WordPress

I will explain step by step how to set up a 404 redirect to enhance user experience and avoid visitors landing on broken links. Setting up a 404 redirect is crucial because it ensures that when someone lands on a “Page Not Found” (404 error), they are automatically redirected to a relevant page—whether it’s your homepage or another working URL. Here’s how I go about setting up a 404 redirect for different types of websites:

On the WordPress platform, there are two popular plugins used for setting up 404 redirects: Yoast SEO and Rank Math. I will explain how to set up 404 redirects using each of these plugins.

WordPress users can easily set up 404 redirects using plugins:

Yoast SEO Plugin

If you’re using Yoast SEO, you can also use their redirect manager (available in the premium version) to set up 404 redirects.

Here’s a step-by-step guide for setting up **404 redirects** using **Yoast SEO Premium**:

Setting Up 404 Redirects with Yoast SEO Premium

1. Install and Activate Yoast SEO Premium:
– If you haven’t already, install and activate the **Yoast SEO Premium** plugin from your WordPress dashboard.

2. Access the Redirect Manager:
– Once Yoast SEO Premium is activated, go to your WordPress dashboard.
– Navigate to **SEO > Redirects** to access the **Redirect Manager**.

3. Creating a 404 Redirect:
– In the **Redirect Manager**, click on **Add New Redirect**.
– In the **Old URL** field, enter the URL that is causing the 404 error (e.g., `/missing-page`).
– In the **New URL** field, enter the page you want the user to be redirected to (e.g., your homepage or a related article).
– Choose **301 Moved Permanently** as the redirect type, which is the best for SEO.
– Click **Add Redirect** to save.

4. Monitor 404 Errors:
– Yoast SEO Premium automatically detects 404 errors and allows you to create redirects easily. You can view any broken links that need attention in the **Redirect Manager**.

5. Test Your Redirect:
– After setting up the redirect, visit the old URL to ensure it correctly redirects to the new page.

By using **Yoast SEO Premium**, you can efficiently manage and fix 404 errors on your WordPress site, ensuring better user experience and improved SEO.

Rank Math Plugin

If you’re using Rank Math for SEO on your WordPress site, you can easily set up 404 redirects using its built-in functionality. Here’s how to do it:

Steps to Set Up a 404 Redirect Using Rank Math:

Install and Activate Rank Math

1. Access the 404 Monitor:
– Once enabled, go to **Rank Math > 404 Monitor**.
– This will show you a list of all the URLs that have returned a 404 error on your site.

2. Set Up Redirects:
– In the 404 Monitor, you’ll see all the URLs that people tried to visit but ended up seeing a 404 error.
– To create a redirect for any of these URLs, click the **Add Redirect** button next to the 404 URL you want to fix.
– You’ll be taken to the **Redirections** section of Rank Math.

3. Create the 404 Redirect:
– In the **Source URL** field, enter the 404 page URL (this will auto-populate if you clicked **Add Redirect** from the 404 Monitor).
– In the **Destination URL** field, enter the URL you want to redirect the 404 page to (such as your homepage or a relevant content page).
– Select the **301 Permanent Move** redirect type (this is best for SEO).
– Click **Add Redirect** to save.

4. Custom 404 Page (Optional):
If you prefer not to redirect users automatically but want to create a custom 404 page, you can:
– Create a new page on WordPress and customize it with helpful links, a search bar, or suggested content.
– Set this page as your custom 404 page in your theme settings or by editing your `404.php` template file.

Monitoring and Managing 404 Errors:
Rank Math’s **404 Monitor** helps you track how often users encounter 404 errors and lets you quickly redirect those URLs to keep your site user-friendly and optimized.

By following these steps, you can easily set up and manage 404 redirects using Rank Math to improve user experience and maintain SEO value on your site.

Another way How to Set Up 404 Redirects in WordPress is through cPanel, and I will explain the process in detail here.

.htaccess (for Apache Servers)
If you’re using an Apache server, you can edit your .htaccess file to set up 404 redirects:

1. Access your website’s root directory via FTP or your hosting control panel.
2. Open or create the **.htaccess** file.
3. Add the following lines to redirect users to your homepage (or any other URL) when they encounter a 404 error:
“`apache
ErrorDocument 404 /404.html
Redirect 404 /404.html http://www.yoursite.com/homepage
“`
4. Replace `/404.html` with your custom 404 error page (if you have one) and the homepage URL with your desired redirect page.
5. Save the file and upload it back to the server.

NGINX Server
For websites hosted on an NGINX server, you’ll need to update your server configuration:

1. Access your server via SSH or through your hosting panel.
2. Open your NGINX configuration file (typically located in `/etc/nginx/sites-available/`).
3. Add the following block to redirect 404 errors:
“`nginx
error_page 404 /404.html;
location = /404.html {
internal;
}
“`
4. If you want to automatically redirect to the homepage:
“`nginx
location / {
error_page 404 = /;
}
“`
5. Reload NGINX by running:
“`bash
sudo service nginx reload
“`

Setting Up 404 Redirect in cPanel
If you’re using **cPanel** for hosting, you can create a 404 redirect as follows:

1. Log in to **cPanel**.
2. Under the **Domains** section, click on **Redirects**.
3. Choose **Permanent (301)** as the redirect type.
4. In the **http://(www.)?** field, select the domain for which you want to set up the 404 redirect.
5. In the **Redirects to** field, enter the URL where you want to redirect users when they encounter a 404 error.
6. Click **Add** to save the redirect.

Custom 404 Pages
– If you don’t want an automatic redirect, you can create a custom 404 error page with helpful information, a search bar, or a link back to your homepage. Custom 404 pages provide a better user experience without forcing a redirect.

Check Google Search Console
– After setting up your 404 redirect, check Google Search Console for any crawl errors related to 404 pages and fix those by redirecting them to the relevant pages.

For More related and helpful content visit Online Period