PHPMatters Help You Better Hosting Your PHP-based Sites
How to Fix WordPress 404 Error?

How to Fix WordPress 404 Error?

A common issue that many WordPress users confront is the 404 error page not found, which is bad for SEO to some degree. When there is such an issue on your website, visitors cannot access to what they want to view, which makes them disappointed. Therefore, we worked out this tutorial to teach you how to fix WordPress 404 error.

What is 404 Page Error?

The 404 page error occurs when someone requests your webpage or post that is not available on the website. For example, when there is an incorrect link on the website or the page has been removed from the site, the error will appear. When this happens, the web server will display an error page that is saying “Page not found”.

The chapters below introduce 2 typical methods to diagnose the issue. However, create a custom 404 error page is the most efficient way to prevent the default and un-designed 404 page displayed to the readers.

Causes for 404 Error and Ways to Fix It

The 2 main issues are,

If the permalink structure of your WordPress site has been changed, your internal pages will be moved to new URLs. When this happens, any link that points to the old URLs will be broken, and here will appear 404 page error on your website.

Resolutions: Resave Your Permalinks Settings

You should go to your WordPress Dashboard to fix the permalinks setting. In specific, hang the pointer on “Settings” to expand it, and then click “Permalinks” in the list.

Permalinks Settings

Then, you should select a permalink you like and scroll down to the bottom of the following page to click “Save Changes”.

Reset Permalinks Settings

What you have done just now will update the permalinks settings and refresh the rewrite rules, and fix the 404 error.

If the issue still exists, you need to login to your server via FTP, and manually update the .htaccess file. To be specific, you should temporarily set the file writeable by changing the permissions to 666. Next, repeat the previous method. Remember to re-change the permissions to 660 after that.

Alternatively, you can manually insert the following code in your .htaccess file:

Insert a Code in Your htaccess File

  • Visitors come across the 404 error if the posts, pages, tags and categories they visit have been deleted from your site.
  • People may be also presented with a 404 error page they happen to click the link that has been misspelled or broken.

Resolutions: Use 301 Redirection

Using 301 redirection is a smart method to fix 404 error. When visitors come to your site and this redirection will lead them to a page that is related to the unavailable content or a page that they can find answers to their original query. To do this, you can install one of the WordPress plugins listed below.

  • Redirection: Redirection is a free WordPress plugin coming with rich features. It provides 404 error monitoring that captures 404 errors on your website and allows you to easily map these to 301 redirects. With it, you’re able to manage 301 redirections and keep track of 404 errors.
  • 404 to 301: With 404 to 301, things can be easy. It can help to handle all 404 errors for you and redirect them to any page or custom link based on your needs and preferences.
  • Eggplant 301 Redirects: Eggplant 301 Redirects plugin helps you easily manage and create 301 redirects for your WordPress site to improve SEO and visitor experience. It has a robust and user-friendly interface, which allows you to create and validate redirects with ease.

How to Enable 301 Redirection Using a Plugin?

Now, we would like to use one of the above mentioned plugins of Redirection to show you how to fix a 404 error page in the following parts.

If you haven’t installed this Redirection plugin, the first thing you need to do is to install it. Specifically, go to your WordPress Dashboard, hang the pointer on “Plugins” and click “Add New”.

Install Plugin

Then, enter “Redirection” in the “Search Plugins” box and find the right one from the search results here on the page. Click “Install Now”.

Search Redirection in the Search Plugins Box

After installing, click “Activate Plugin”.

Activate Plugin

After installing and activating, go to “Tools” under Dashboard on the left side menu and click “Redirection” in the expanding list as the screenshot shows below.

Redirection Plugin

Now, you can see a page like this.

Redirections Page

Before having any further move here, you need to go to your Google Webmasters tool account in the browser and click the domain name that you want to analyze and deal with 404 error. Next, click “Crawl” to expand it and then click “Crawl Errors”. On the right side, you’ll see a list of 404 error results.

Crawl Errors

You can click any of the links and there will be a pop-up window displaying that detailed 404 error information, including the crawl time and detect time.

404 Error Information

To create a 301 redirection for this 404 error, return to your WordPress Dashboard, click the “404s” link on the “Redirection” page, and you will see the source URL captured on the Google Webmasters error page. Then, you can create a 301 redirection for the URL and direct it to other page on your site. Click the “Add redirect” link.

404 Error URL

On the bottom of the page, you can find the section of “Add new redirection”. Here, you should enter the URL which you want to redirect in the “Source URL” box, and then enter a valid destination URL in the “Target URL” box. This is where your 404 error page will be directed to when visitors click it. Once done, click “Add Redirection”.

Add New Redirection

After you have created the 301 redirection successfully, click the “Redirections” link and you can see the record on the page. Here you’re able to see the number of hits this URL received.

Redirection Record

Things haven’t finished yet. You need to return to your Google Webmasters tool account once again, and find the 404 error URL you have fixed just now, and then click “Marked as fixed”.

Confirm Fixed 404 Error