wordpress 404 error

404 Errors – Only Home Page works [WordPress Migration]

WordPress is giving me 404 pages not found for all pages except the homepage. We all know that the most potent CMS ever released is WordPress. Now WordPress powering over 30% of the internet. Although WordPress is a powerful CMS, sometimes a slight tweak can make your website inaccessible. However, finding a solution for any WordPress problem is extremely easy. Like the internal server error or error establishing the database connection. Another common problem that most WordPress users face at some point is WordPress posts returning a 404 Error. In this article, we will show you how to fix WordPress posts returning 404 error. Fix WordPress 404 error below.

Also read: MySQL on ubuntu keeps crashing

How to solve wordpress 404 error

First of all, we need to check whether the admin area is accessible or not if it is we can efficiently resolve the error. If the blog’s main page/homepage is accessible and in the case of single posts they get a 404 Not found error. First of all, don’t panic most of the time your posts are still there and completely safe. This usually happens if your .htaccess file got deleted or something went wrong with the rewrite rules. What you need to do is fix your permalinks settings.

Trending posts:

My personal experience

All of a sudden I go to my WordPress website and all the pages except the homepage give me a 404 page not found page. I’m assuming the problem lies with the permalink structure, which I could swear I did not touch. The permalink setting was set on “post name”. So changing the permalink structure will resolve the problem but, we need to try different methods for the same. I suggest you try one of the methods provided below and will surely solve the error.

Trending posts:

Method 1: Change WordPress permalinks

This will update your permalinks settings and flush rewrite rules. In most cases, this is the perfect solution for the WordPress posts 404 error. However, if it does not work for you, then you probably need to update your .htaccess file manually.

Method 2: Edit .htaccess

Login to your server using FTP, and modify the .htaccess file which is located in the same location where folders like /wp-content/ and /wp-includes/ are located. If you are not able to find the .htaccess file create one or may be hidden by default. The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 666. Then repeat the original solution. Don’t forget to change the permissions back to 660. You can also manually add this code to your .htaccess file:

# 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]
# END WordPress

Method 3: AllowOverride None to AllowOverride All

Open the Apache virtual file for your domain to make changes:

sudo nano /etc/apache2/sites-available/000-deafult.conf

Make these additions on the file

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/mysite
    ServerName server_domain_name_or_IP
    <Directory /var/www/mysite>
        AllowOverride All
    . . .

Save and exit then enable mode rewrite which allows you to modify URLs:

sudo a2enmod rewrite

Reload Apache

sudo service apache2 reload

Related threads:

Leave a Reply

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