How to Fix WordPress 404 Errors When the Post or Page Does Exist
What’s more frustrating than getting a “404 page not found” error in WordPress when your pretty permalink page, post or custom post type does exist?
Possibly, seeing the white screen of death when you upload images, which can also happen.
Don’t worry, you’re not in the twilight zone or a parallel reality and they do exist.
The problem lies with the Apache extension
mod_rewrite since it’s not enabled or set up properly and it can’t rewrite your URLs to use the pretty permalinks you previously selected.
Here’s how to fix your
parallel reality pretty permalinks to get rid of these selective 404 errors on your posts, pages and custom post types as well as how to fix the white screen of death that resulted from uploading those images.
Resetting Pretty Permalinks
A permalink is a permanent URL to your posts, categories, archive and other similar pages. It’s the unique link that directs to a specific, corresponding post.
A pretty permalink is a more detailed URL than the default option. Instead of displaying only the ID number of your post and not much else, pretty permalinks can also include the year, month and day your post was written as well as the post title and other similar options.
When you install WordPress, you’re automatically set up to use pretty permalinks, though, you need to choose what you want to be displayed in them.
If the Apache
mod_rewrite extension gets disabled or there are plugin and theme conflicts, these types of links stop working.
Resetting your pretty permalink settings should fix this issue with
mod_rewrite if uploading images causes the white screen of death or if your posts or pages are returning a 404 error. Doing this flushes the current rewrite rules and you can try to do this automatically or manually.
If your custom post types are the subject of the 404 error, then look to the next section for the solution.
Automatically Resetting Permalinks
In your admin dashboard, go to Settings > Permalinks and make note of the current setting since you need to temporarily change it. Select the Plain radio button and click Save Changes at the bottom of the page.
Once saved, click the previous pretty permalink option you had and click Save Changes one more time.
Your permalink settings have been reset and you can check your posts, pages, and images. You shouldn’t see any more 404 errors or white screens of death.
If this doesn’t work, try manually resetting your permalinks.
Manually Resetting the .htaccess File
To manually reset your permalinks, you need to be able to access and edit your .htaccess file located in the root of your site. You can access this file through FTP, SSH and the command line or cPanel.
You have two options for editing this file: download a copy of your .htaccess file, edit it in a compatible text editor, then reupload it to your site replacing the original file or you can use SSH or an FTP client such as FileZilla to edit your .htaccess file directly on your server, then save your changes.
Keep in mind that before you edit WordPress files, you should backup your site first. If something goes wrong, you can restore your site and try again.
Depending on your setup, you may have more than the default code in your .htaccess file, but all you need to edit is the inherent code so be sure to leave everything else intact.
If you didn’t make any custom modifications to your .htaccess file, you can delete it instead of doing any edits. Then, go to your admin dashboard and click the Save Changes button on the Settings > Permalinks page. The file should be automatically regenerated.
To manually reset the .htaccess file, edit it and replace the default code with one of the snippets below that’s relevant to your setup, then save the file. The code you need to replace should look similar to the snippets below.
For single installations of WordPress, copy and paste this:
For subdirectory installations of WordPress Multisite, use the code below:
1.6 million WordPress Superheroes read and trust our blog. Join them and get daily posts delivered to your inbox - free!
On the other hand, if you have a subdomain install of WordPress, use this instead:
If you have version 3.4 of WordPress or below installed, refer to the WordPress Codex’s .htaccess page for the code you need.
Once you have saved the file and it’s on your server, the rewrite rules are flushed and the errors should be resolved.
Fixing Custom Post Types
Fixing 404 errors on custom post types is a little different because there’s an added step involved. You need to check each of your custom post types for both unique titles and slugs.
If two or more posts contain the same title or slug, they need to be changed. Only one post can contain that title and slug so be sure to change the others to something unique.
It’s also not enough to change either the title or the slug. Both need to be updated.
Resetting Permalinks to the Default
To remove the 404 error for custom posts types, reset your permalink settings. You can do this automatically or manually with the same details mentioned above.
Once that’s done, you shouldn’t see the error anymore and you can visit the URLs of your custom post types to confirm that the issue has been fixed.
In cases where the above doesn’t resolve the errors, check to make sure your .htaccess file is set up with the proper permissions so WordPress can write to the file. For details, check out Understanding File Permissions and Using Them to Secure Your Site.
If you needed to update the permissions, try the steps above again. There may be a plugin or theme conflict if your errors are still persistent.
To troubleshoot the issue further, activate the default WordPress Twenty Seventeen theme by going to Appearance > Themes in your admin dashboard. Hover over the default theme and click Activate.
Next, check your site to see if the 404 errors or white screen of death are gone and if they are, the theme you were using is the culprit. You can contact the theme author and report the issue so they can fix it and release it in a future update.
If the errors still appear, then you can switch your theme back to the one you were previously using and deactivate all your plugins instead.
Go to Plugins > Installed Plugins. Then, click Deactivate for each of the listed plugins or bulk deactivate them all by clicking the Plugins checkbox toward the top, choose Deactivate in the dropdown box next to it and click Apply.
Now check to see if the errors have left the building, so to speak. If that did the trick, then reactivate your plugins one by one all the while, checking your posts in between each activation until the error reappears.
When it does, the last plugin you activated is the cause. To fix it, notify the plugin author so they can fix it. In the meantime, you can search for a suitable alternative that you can use until the issue is resolved.
Get Superhero-level Help
There’s expert WordPress help available if these steps don’t seem to make a difference in resolving the errors.
You can get assistance in resolving this issue as well as any other WordPress issue you may have with our five-star support team. Our expert support team is only a click away on any given day.
If you’re already a WPMU DEV member and you have questions, ask away! You can get help for free. You can browse through our support forum to find the answer you need and ask your questions through our 24/7 live chat where we usually respond in under a minute.
You were certain your pages, posts, custom post types existed even though your browser returned a 404 error and you were right. Now you now how to fix the problem and quickly to boot.
If you uploaded images and got the white screen of death, you now know how to fix that, too.
You can also check out the WordPress Codex page on pretty permalinks more detail on them.