WordPress is a pretty reliable CMS for the most part. After all, it’s been tested and retested on millions of sites all over the world, and most the kinks have been worked out. Despite all that, it sometimes behaves unexpectedly – like when you suddenly see a 404 “Not Found” error where you shouldn’t. Maybe you updated a plugin or a theme, or were fiddling around with some options, and you suddenly couldn’t access a page that you could before!
This is usually a result of a configuration error in .htaccess or in the permalink settings. The good news is that it’s not serious and can usually be fixed in a couple of steps. In this tutorial, I’ll show you how so you can get back up and running in a jiffy!
So let’s say you have a 404 error on a page that was rendering perfectly before. Like this:
Note the URL structure on this file. It’s
https://www.nameheroreview.com/blog/how-to-paste-code-properly/
Method 1 (Preferred): Resaving the Options in Permalinks
If you have access to your admin pages, then you’re in luck! This is the preferred method to resolve unexplained 404 errors since you won’t have to mess around with internal WordPress files. In fact, there’s no need to even take a backup of your site because this is a completely safe procedure.
Go to your WordPress admin, and click “Settings -> Permalinks” on the left-hand side as shown here:
Here you’ll see a number of options for the permalinks, and one of them should already be selected for you. It’s most likely the one that matches the existing URLs for your blog posts. In this case, it’s the one with the /blog/post-name. If another one is selected, make sure to change the option back to the one that matches your desired blog URL.
Once done, scroll down and click “Save Changes”. That should fix the problem! This resets the internal WordPress rules and usually fixes any pesky 404 errors.
However, you might not have access to the WordPress admin interface. In which case, we need to go nuclear.
Method 2: Manually Reset the .htaccess File
This method will require you to go into your backend and modify a hidden file in the root folder of your WordPress site called “.htaccess”. If you don’t have FTP setup, the easiest way is to log into the cPanel account of your hosting provider and select the file explorer as shown here:
Now navigate to the directory hosting your blog. You’ll know it’s the right one because you’ll also see other folders like “wp-admin”, “wp-includes” and “wp-content”.
If you don’t see these folders, you’re in the wrong directory!
Along with these, there should be a file starting with a dot (.) followed by “htaccess”. This is our target. First, take a backup by right-clicking it and making a copy. Give it some easily recognizable name. Next, right-click the original file and click “Edit”. In the dialogue box, click the Edit button to start editing.
Now delete everything inside and paste these fresh rules into it:
# 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
Note: If you can’t find a “.htaccess” file in your blog root directory, then you need to create one manually.
Once you’ve pasted these changes, save the file. Now you should once again have access to the WordPress admin area. Follow the steps outlined in “Method 1” to be sure, and you should be able to once again access your blog’s pages!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Fatima Barbosa Dos Santos Yoshino says
Your instruction is so perfect!
Thank you
Vela says
Thank you for the information.