• Categories
    • Tutorials
    • Beginners Guide
    • WordPress News
    • WordPress Security
    • Best WordPress Plugins
    • WordPress Themes
    • Product Reviews
    • WP Tips & Tricks
  • Guides
    • Start a Blog
    • Make a Website
    • WordPress Hosting
  • WordPress Hosting
    • A2 Hosting
    • HostGator
    • Bluehost
    • Cloudways
  • Managed Hosting
    • WPEngine
    • Rocket.net
    • WPX
    • Kinsta
  • Coupons
    • WPEngine
    • Flywheel
    • Cloudways
    • A2 Hosting
    • WPX Hosting
WordPress Tutorials

How to Fix the WordPress Post Returning a 404 Error Issue

Last Updated on: September 12, 2016 Lyn 3 Comments

How to Fix the WordPress Post Returning a 404 Error Issue

A 404 error appearing when you click on one of your WordPress posts is a strange issue to have, but the solution is fairly straightforward, thankfully. Unfortunately, there’s no clear reason as to why this issue occurs, making it difficult to prevent.

It has to do with your site’s permalink structure, which is partially controlled by the .htaccess file. You’re more likely to experience this issue if you use custom or “pretty” permalinks as opposed to WordPress’ default setting.

That doesn’t mean you shouldn’t use pretty permalinks. It just means your .htaccess file got deleted or corrupted in some way, shape or form, and you need to correct the issue as it’s causing the 404 error to appear in your posts.

Solution #1: Fix the 404 Error by Resetting Permalinks

This issue is typically caused by a corrupted .htaccess file, as stated earlier. Yours may have gotten deleted or corrupted somehow, causing this 404 error to appear when you click on a WordPress post.

Thankfully, there’s an easy way to generate a brand new shiny .htaccess file that doesn’t require leaving the WordPress admin area. All you need to do is open the Settings menu, and select Permalinks to navigate to your Permalinks settings page.

404 Error Update Permalinks

Scroll down to the bottom of that page, and click Save Changes. This does a number of different things, including cleaning up your file’s rewrite rules. It should be enough to fix the 404 error in most cases. Continue to the next solution if it doesn’t.

Solution #2: Reset Rewrite Rules Manually to Fix the 404 Error

If the simple two-click solution doesn’t work, you may need to do a little more work and reset your .htaccess file’s rewrite rules manually. You’ll need to access your site through an FTP server to do this. We’ll show you how to connect your site to an FTP server via FileZilla in this tutorial. You can also use Cyberduck.

How to Set Up FileZilla

Note: Feel free to skip these instructions if you have experience using FTP clients.

FileZilla is a computer program you can use to access your site’s files from your own computer using an FTP server. We need to download the software to start out with. Click here to download FileZilla. Make sure you choose a version that’s compatible with your operating system.

Once you install the program on your computer, open it, click File in the menu at the top, and select Site Manager.

Enter your site’s name to label your site’s FTP server, and enter the following settings:

  • Host – Your domain example.com
  • Port – Leave blank.
  • Protocol – FTP – File Transfer Protocol
  • Encryption – Only use plain FTP (insecure)
  • Logon Type – Normal

Enter the username and password you use to access your site’s control panel through your host as your username and password for FileZilla. If your host uses cPanel, use the login credentials you use to access cPanel.

Open the Transfer Settings tab. Tick the box for Limit Number of Simultaneous Connections, and enter 8 as the Maximum Number of Connections. Click Connect to connect to the FTP server.

Manually Resetting Rewrite Rules for the .htaccess File

Root Directory public_html

Open your site’s root directory in FileZilla. This is typically called public_html. If you see folders called wp-admin, wp-content and wp-includes, you’re in the right place. This is where your .htaccess file is located. However, .htaccess is a “dotfile,” which are hidden in some file managers by default.

Force Showing Hidden Files

If you do not see a .htaccess file in your site’s root directory, you may need to force the FTP client to show hidden files. If you’re in FileZilla, click Server in the menu at the top, and select Force Showing Hidden Files.

.htaccess File Writable

Once you find your .htaccess file, right-click it, and select File Permissions. You can attempt to fix this issue by making the .htaccess file writable temporarily. Enter 666 as the Numeric Value to do so, and click OK to save that setting.

Refresh FileZilla Files

Click Refresh at the top of FileZilla to refresh your site’s files. Go back into WordPress, open your permalink settings, scroll down to the bottom of the page, and click Save Changes.

Go back into FileZilla, and change the file permissions for .htaccess back to 644 for security purposes. Refresh the FTP client when you’re done.

Solution #3: Adding Code to your .htaccess File

Your .htaccess file should have a specific snippet of code inside of it. If your file has been corrupted in some way and you are unable to create a new one using the simple techniques explained above, you may need to add its original code into it.

Use the instructions above to access your site’s files through an FTP server so you can access your .htaccess file. Once you find it, double-click it to download it to your computer. Open it with a text editor, such as Notepad or TextEdit.

.htaccess File Code

See if this code is in there. Study this code compare it with the code in your file to make sure nothing is missing as the simple omission of a forward slash or other character can cause issues.

Copy and paste this code into your file if it’s missing or if you sense there are issues. You can also replace this code with your current code if you simply wish to see if it will work:

# 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

Save the file.

Uploading the File to Your Site

Again, skip these instructions if you already know how to upload files to an FTP server.

Basically, FileZilla has four panels. Use the bottom two panels. The one on the right contains the root directory for your site. Use the one on the left to navigate to the folder that contains the .htaccess you edited on your computer.

Upload Edited .htaccess File

Drag the file from the left panel over to the right panel, overwriting the original file when prompted. Refresh the FTP client, and see if the issue is fixed on your site.

How to Fix the 404 Error on a Local Server

If you are using a local server running on MAMP, WAMP or XXAMP and are experiencing the 404 error issue with your WordPress posts, you may need to enable a module called rewrite_module. This is especially true if you wish to use custom or “pretty” permalinks.

Open the application for your server, and open its menu. Hover over Apache and then Apache Modules. Make sure the rewrite_module is checked. Check it if isn’t. This should fix the permalink issue as well as the 404 error issue.

Solution #2: Editing the Code on Your Local Server

The solution above is a quick way to enable custom permalinks on a local server. If you’re having issues enabling them, do so manually.

Open your server’s folder, and find the Apache folder. Open the Conf folder, and open the httpd.conf file inside of it.

Locate this line, and remove the pound # sign from it:

#LoadModule rewrite_module modules/mod_rewrite.so

Save it, and test your WordPress post to see if the 404 error is gone.

Malware and Help from Your Host

Some users have experienced recurring instances of the 404 error issue as the result of malware, though this is rare. If you go through the steps above and fix the issue only to have it return shortly later, you may want to investigate the possibility of your site having been infected by malware.

The best way to prevent malware is to make sure you are only install highly-rated themes and plugins on your site. You must also keep your theme, plugins and WordPress up to date as much as possible as the updates developers release contain key security fixes.

Check out this guide on how to scan your site for malware if you suspect your site has been affected by malware.

If you simply cannot find a way to fix this issue, consider contacting your host. They may be able to help you identify the issue, pinpoint where it’s located and fix it.

Final Thoughts

The WordPress post returning a 404 error issue can be a little frustrating, but the solution is a lot easier to find than most other issues in WordPress.

There’s no sure fire way to prevent this issue from happening, but if you have access to your site’s server logs, you may be able to pinpoint the exact reason it occurred. Again, knowing this likely won’t prevent the issue from happening again, but it may be nice to know.

Your best bet is to keep everything on your site as up to date as possible, make backups on a regular basis, and keep things secure.

Check out these guides if you want to learn how to keep your site running in tip-top shape:

  • WordPress Security 101
  • How to Improve WordPress Security with WP Security Audit Log
  • 7 Top Backup Plugins for Your WordPress Site
+ Share
Disclosure

Lyn

Related Posts

Back to all articles
  • How to Increase the Memory Limit in WordPress

    How to Increase the Memory Limit in WordPress

  • What is WordPress? A Beginner's Guide!

    What is WordPress? What Can it do & Is it Right for You? A Beginner’s Guide

  • How to Use Git to Push Your Local Site Live

    How to Use Git to Push Your Local Site Live

Coupons

View more deals
  • Recipe Card Blocks Coupon
    15% OFF

    Recipe Card Blocks Coupon

    Running a cooking or food website can be fun (and tasty) – but
    Get This Deal
  • WP 2FA Coupon
    20% OFF

    WP 2FA Coupon

    Security should be at the forefront of all site owner’s min
    Get This Deal
  • Themskingdom Coupon
    20% OFF

    ThemesKingdom Coupon

    First impressions count. As such, you’ll want a WordPress t
    Get This Deal
3 Comments Leave a Reply
  1. Awontis says

    October 4, 2016 at 11:26 am

    Very informative and useful article for WordPress beginners!

    Reply
  2. Melissa says

    October 5, 2016 at 9:56 pm

    Great Post!

    Apart from actually fixing the issues that cause 404 errors, I like to use plugins to redirect invalid links to home page. This way, typos in URLs are forgiven instead of losing a reader.

    Reply
  3. people at nusa says

    May 4, 2017 at 6:51 am

    Many hours trying different solutions from other blogs/sites.
    Solution #3 worked for us in our local servers.
    (Note that “Solution #3: Adding Code to your .htaccess File” works also for local servers. It may sound obvious to many but not to beginners.)
    Site bookmarked…

    Thanks a lot!

    Reply

Leave a Reply Cancel reply

Full Disclosure This post may contain affiliate links, meaning that if you click on one of the links and purchase an item, we may receive a commission (at no additional cost to you). All opinions are our own and we do not accept payments for positive reviews.

THE BEST OF WPKUBE

Some of the best content we have published so far.

BEGINNER GUIDES & REVIEWS

18 Best Cheap WordPress Hosting Providers in 2023 (From $1.99)
210 Best WordPress Hosting Options for 2023 (Pros & Cons)
38 Best Managed WordPress Hosting Providers for 2023 Compared
45 Best WooCommerce Hosting Providers Compared in 2023 (All Budgets)
5Top 9 Landing Page Plugins for WordPress (2023)
69 Best List Building Plugins for WordPress In 2023
7How to Fix the 500 Internal Server Error on Your WordPress Website
8Thrive Themes Review: A Look At The Full Membership
9Beaver Builder Review: Is it The Best Page Builder Plugin for WordPress (2023)?
10OptimizePress Review: Create Landing Pages with Ease
11How to Make a Website: Complete Beginner’s Guide
12Top 22 Best Free Stock Photo Resources For Your Site
1317 of the Best Google Fonts for 2023 (And How to Use Them in WordPress)
14How to Start a Blog in 2022 (Step by Step Guide)
15How To Fix ‘503 Service Unavailable’ WordPress Error
1611 Best Contact Form Plugins for WordPress in 2023
17How to Add a Custom Logo to Your WordPress Site
18How to Fix Error Establishing a Database Connection in WordPress

WPEngine: 50% OFF Deal

Save 50% on one of the best managed hosting providers.

Get this Deal

Flywheel(our review)

Our Newsletter

Get awesome content delivered straight to your inbox.

Thank you!

You have successfully joined our subscriber list.

.
Featured In Forbes Huffpost Entrepreneur SEJ

About WPKube

WPKube is an online WordPress resource which focuses on WordPress tutorials, How-to’s, guides, plugins, news, and more. We aim to provide the most comprehensive beginner’s guides to anything about WordPress — from installing plugins, themes, automated installs and setups, to creating and setting up pages for your website.

We have over 500+ tutorials, guides, product reviews, tips, and tricks about WordPress. Founded by Devesh Sharma, the main goal of this site is to provide useful information on anything and everything WordPress.

Twitter Facebook

Useful Links

  • Behind the Scenes
  • Beginner Guides
  • WordPress Hosting
  • WooCommerce Themes
  • MeridianThemes
  • Exclusive WordPress Deals
View All Guides »

Reviews

  • WPEngine 33% OFF
  • Thrive Leads
  • Flywheel 33% OFF
  • Divi Theme 20% OFF
  • Thrive Architect
  • Elegant Themes
Reviews »

Deals

  • InMotion Hosting
  • LifterLMS Coupon
  • LiquidWeb Coupon
  • WPEngine Coupon
  • A2 Hosting
  • FloThemes
More Deals »
© Copyright 2023 WPKube ® All Rights Reserved.
  • Contact
  • Site Terms
  • Disclosure
  • Privacy Policy