BACK TO TOP

How to Fix the “404 Not Found” WordPress Error

How to Fix the 404 Not Found WordPress Error

One of the most common issues that appear for WordPress websites is the 404 Not Found WordPress error. Luckily, it is fairly easy to solve compared to the other WordPress errors. It’s rarely a sign of a serious problem, but it can still have a negative effect on user experience. The error can happen during access to theme assets (images, CSS or JS files) and pages. Most often, it shows up on WordPress posts. The error message can vary but usually includes the following phrases: not found, can’t find, Error 404 or just 404.

In this article, we will guide you through the solutions that are known to help with this error. They aren’t restricted to posts only – you can apply them in any situation when the 404 Error occurs.

Small tip before we begin: since 404 Errors are virtually impossible to avoid, it is also important to improve the user experience when they happen. You can do this by customizing the look of your 404 Error page. Some themes, like the ones we provide at Qode Interactive, offer these customization options, while others require the use of third-party plugins.

Here’s an example of a customized 404 page.

404 Error page

In this article, we’ll cover the following troubleshooting options:

Preliminary Steps

Before you look for the cause of the issue, make sure the error wasn’t only temporary. While it may seem needless, we strongly recommend you take these preliminary steps before delving into more complicated ways to deal with the 404 Error.

Removing Invalid Links

Occasionally, an admin user or site editor delete an article and move its content elsewhere, but forget to remove the broken link from the menu of the site. This is one of the more common causes of the 404 Error. In this case, all it takes is removing or editing the menu links that lead to non-existent posts. Do the same with the broken page URLs.

To remove invalid links, navigate to Appearance > Menus and select the menu currently in use.

Broken menu item

Find the invalid menu item and delete it.

Delete broken menu item

Click on Save Menu to save the changes.

Save menu item

Afterward, you can add a new menu link with the proper URL and drag it to the desired location within the menu.

Removing Typos

Typos are another common cause of error 404. Make sure that the page/post URL is correctly typed, especially if you are typing it manually. For example, inserting your-site-name/blof instead of your-site-name/blog can cause the error, so make sure to check carefully.

Clearing the Cache

With browser-related troubleshooting, it is also recommended to make sure that the error isn’t caused by caching. Clear the browser cache and try accessing the page, post or theme asset once more. You can also access it in another browser or an incognito window inside of your current browser.

Solving the Error

With browser-related troubleshooting, it is also recommended to make sure that the error isn’t caused by caching. Clear the browser cache and try accessing the page, post or theme asset once more. You can also access it in another browser or an incognito window inside of your current browser.

Also, create a backup of your WordPress site. If you don’t feel comfortable doing it yourself, ask your hosting provider to do it for you.

Saving Permalinks

If the 404 Error is present on the entire site, it is likely caused by a permalink issue. On WordPress posts, it happens when you click to view a post. This can be quite frustrating, especially after you’ve just created a post and added all the content.

If you are experiencing this issue, don’t worry. Your post is still there and all you need to do is update your permalinks. Navigate to Settings > Permalinks and click on Save Changes in the lower-left corner of your screen.

Save permalinks

The issue with viewing the posts is most often caused by the changes in the permalink slug of a custom post type. Most premium themes, apart from default post types, offer their own post types. They also might include the option to change the permalink slug of that custom post type.

Qode Interactive themes offer this option. The option included within these themes has a note that states: After entering slug, navigate to Settings > Permalinks and click on Save in order for changes to take effect.

Portfolio permalink slug

Using a plugin to change the permalink slug of a custom post type is also a common cause of the issue, especially for themes that lack the permalink options. If you are using this type of plugin, make sure to update your permalink settings after changing the slug.

Making a Default .htaccess File

Another way to solve the 404 Error is to manually edit the .htaccess file. This solution requires an FTP client like FileZilla and the knowledge of editing files via FTP.

As the .htaccess file is a hidden server configuration file, you need to enable viewing hidden files in the chosen FTP client. To do this in FileZilla, navigate to the Server tab and click on Force showing hidden files.

Force showing hidden files

After setting the options, go to the root directory of your WordPress site, find the .htaccess file, right-click on it and select View/Edit.

Htaccess edit

Before the edits, download the file and save that version as a backup on your computer. You can see the download option on the screenshot.

To restore the default .htaccess file, add the following code and save the file. Upload it to the server, overwriting the one that’s currently there.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Clean htaccess file

Run a test to see if the error is resolved. If it isn’t, re-upload the stored backup version of the file.

If you have trouble implementing this solution due to insufficient file permissions, you can temporarily change the permission of the .htaccess file to 666. Do it by right-clicking on the .htaccess file, from your chosen FTP client, and selecting File permissions.

Htaccess permissions image

Afterward, manually insert 666 in the numeric value box and press OK.

Htaccess permissions image

Having changed the file permission, restore the default .htaccess file as we previously described.

When you’re done, revert the permission of the .htaccess file to the old value, which can be 644 or 660.

Qode WordPress Themes: Top Picks
Bridge WordPress Theme Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

Biagiott banneri
Biagiotti

Beauty and Cosmetics Shop

Additional Troubleshooting Steps

On rare occasions, none of the solutions we described will solve the issue. For those cases, here are 2 additional steps known to successfully troubleshoot general WordPress errors.

Disabling mod_security

Mod_security is an open-source software used for site protection and access-control. This is achieved using certain rulesets, namely ModSecurity Core Rule Set or self-made rulesets.

However, mod_security rules are known to give quite a few false positives regarding the daily use of a WordPress site. Therefore, you need to make certain ruleset exclusions. This can be difficult if you are implementing numerous rules, so the best way to deal with this issue is to temporarily disable the mod_security altogether.

This can be done by editing your .htaccess file via FTP. Add the following code at the top of your .htaccess file.

<IfModule mod_security.c> 
SecFilterEngine Off 
SecFilterScanPOST Off 
</IfModule>
Htaccess mod security code

Afterward, test if the issue is resolved. If not, remove the code to avoid creating security issues.

Disabling Plugins and Theme

As it is important to be thorough, testing your plugins and theme should be included in every troubleshooting process. Deactivate your plugins one by one. After each deactivation, try to access the page, post or theme asset.

If the error is resolved, the last deactivated plugin is the culprit.

If you skipped backing up your site at the beginning of troubleshooting, don’t skip it at this point. Continue by switching your theme to a default one (e.g., Twenty Twenty) and run the test. If the error disappears, then your theme is the source of the problem. In that case, contact the theme’s customer support for further assistance.

Final Thoughts

Apart from solving your problem, you had an opportunity to learn how your website works. Keep this tutorial on how to fix 404 Not Found WordPress errors in your bookmarks, since you’ll likely run into the error again. Be fully prepared when it happens next time!

Post your comment

Comments0