How to Fix the 404 Error for WordPress Websites?

Spread the love

When browsing, you must have noticed several instances of 404 Error. It is quite common and thankfully rather benign. Nothing is really wrong with your site. It has a touch of the flu.

While the 404 is mostly generated because of client-side mistakes (for example, typing the wrong URL or not clearing browser cache) you have to ensure that your WordPress site is working perfectly.

It’s not that 404 never happens due to server-side problems. Before you hire a WordPress expert to take a look at the setup, these are the initial first steps you can take.

What is the 404 Error?

The “404 Not Found” (also variants such as Error 404, HTTP 404, and Error 404 Not Found) is an HTTP standard response code when a browser receives no reply from a server.

When you type an URL into the address bar of a browser, it sends a request (through DNS name server) to the server on which the requested site resides.

If the server cannot locate the page, file, or image that was requested, it would return a 404 message.

It is simply the server’s way of saying “I can’t find what you want me to”.

How to fix the 404 Error?

First of all, there is nothing you can do to prevent a visitor from mistyping your URL.

If a landing page is located at www.myecommercesite.com/?256 but the client types www.myecommerceite.com/?256 it would return a 404 error.

But what can you do to make your WordPress website perfect? There are several methods and let’s look at them one by one.

1. Set Permalinks

Permalinks mean permanent links.

For example, www.myecommercesite.com/?256 is actually the product page for red cashmere stoles for women.

Logically it should read www.myecommercesite.com/red-cashmere-stoles-women but the default settings on WordPress would make it www.myecommercesite.com/?256 where 256 is the page ID in the database.

Login to WordPress and go to Settings. Click Default and Save Changes.

Also, you could opt for a custom structure.

Not only does enabling permalinks help with 404 but also fixes the URL. Google can understand what that page is about.

Important—For best results, you need to do this right after you publish the site.

Next, clear your browser cache and try to view the webpage. It should render smoothly.

2. Manual Correction

If the above does not fix your problems, it is time to fix them manually.

You need to edit the .htaccess file.

The .htaccess file is a server configuration file that protects admin rights and processes redirects. You can find it in /wp-includes and /wp-content folders. It is a root file and therefore be careful when you edit it.

The dot before the filename indicates it is a hidden file. Use the cPanel File Manager to show hidden files.

Now login to the server using FTP (use a tool such as FileZilla) and add this code to the .htaccess file

# BEGIN WordPress

<IfModulemod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Paste, save, and close the file. Since this code also resets the .htaccess file you might need to open Settings and perform the steps above.

Remember to change .htaccess back to hidden.

3. Disable Plugins

If even after the above you keep getting 404 messages when you test your WordPress site, the problem might lie with a plugin.

Plugins are software that attaches to the WordPress platform and provides functionality, such as email management, CRM, SEO, etc.

While most are well tested there are often issues with the way plugins interact with each other.
Open the dashboard and head to Plugins > Installed Plugins.

Disable or deactivate them one by one and test if the 404 problem is resolved. Usually, this step works effectively.
It is akin to switching off browser extensions on Chrome and Firefox ifthey malfunction.

4. Set up 301

This is the last weapon in your arsenal. If it does not work you have no choice but to call in a WordPress developer.

Logically, 404 can happen only if the URL you are typing is not present in the WordPress database.

Let’s say the page www.myecommercesite.com/red-cashmere-stoles-women was accidentally renamed or reverted to www.myecommercesite.com/?256 and now you are unable to match a URL to the content on the page.

Set up a fresh page on your WordPress site. Copy the content of the old page to the new one.

Now redirect all traffic from www.myecommercesite.com/red-cashmere-stoles-women to www.myecommercesite.com/red-cashmere-stoles-women_1

You can use a tool such as Redirection or do it from cPanel.

A word of caution.

Every step mentioned above will cause fundamental changes in your website, files, directory, and SEO.

Before you proceed be sure to get a backup so that if anything goes wrong you can reverse it.

Where to find the hidden page?

You might get obsessed regarding the page ID under which the content is hiding. There is an easy way to search.

In Google, type red cashmere stoles site: www.myecommercesite.com

Google would search all the pages for the words “red cashmere stoles”.

Assuming there is such a page (that was not later deleted) you could try to rename it or simply set up a fresh page followed by a redirect and delete the original one.

Of course, the same search can usually be done from the WordPress admin panel > Posts unless the content has disappeared entirely.

Setting up a custom 404 page

A normal user does not know what 404 Error is.

They cannot understand the difference between 401 (Unauthorized Request) and 404 and 403 (Forbidden).

Most likely he or she is looking for something they thought you sold or provided. Being confronted by a 404 message is not likely to elicit a favorable reaction.

Give them some content on a custom 404 page so that they don’t hit the back button and bounce away.

Design a page that says the content requested does not exist and give a button with a hyperlink to take them back to the Home Page.

It is quite easy to do.

Create a simple page at www.myecommercesite.com/404.html

It should have a funny message or a tongue-in-cheek apology and a link back to Home Page.

Now open .htaccess and add this line

ErrorDocument 404 /404.html

Next test by typing in the address bar something like www.myecommercesite.com/98765 (a page that does not exist).

It should take you to the custom 404 page.

Why make the effort?

You are trying to minimize bounce.

Using a custom 404 page, you would most likely redirect the visitor to the home page.

While that is hardly satisfactory, if you were looking to make sales, it at least keeps the visitor on your site a little longer.

There is another task you must do at regular intervals.

Check your site using the Broken Link Checkertool by Ahrefs. Any 404 would show up.

Alternatively, you could also use Google Analytics > Behavior > Site Content > All Pages.

Optimizing WordPress

404 error is just one thing that can go wrong with your WordPress website.

Many problems can arise and the troubling fact is most are invisible. You don’t learn about them till someone brings it to your notice.

Pages with askew images, slow loading on mobile, navigation that does not work like it is supposed to—the issues are myriad.

You need to hire a WordPress developer to not only set up your site but also give it a tune-up at intervals and keep everything running in tip-top shape.

Leave a Reply

Your email address will not be published. Required fields are marked *