[Fix] 404 Not Found on WordPress Pages After Moving to a New Server (Apache)

I’ve recently moved one of my WordPress sites to a new server, and while the migration was successful, I was getting this Apache2 error: “404 Not Found. The requested URL was not found on this server“. My homepage was opening fine, however, all my posts and pages were showing 404 errors. If you’re seeing the same error on your site, try these fixes:

404 Not Found Apache

Table of Contents - Article Hierarchy

Debug 1:

Step 1: Log into your WordPress dashboard.

Step 2: Go to Settings >> Permalinks.

Step 3: Select your preferred permalink structure and click on “Save Changes”.

Debug 2:

Step 1: Log into your server via FTP or SSH, and edit the .htaccess file found in the root directory of your site. If you don’t have one there, please create one.

Step 2: Add the following code to the .htaccess file and save 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

Debug 3:

Step 1: Log into your server via SSH.

Step 2: Type in the following commands:

sudo a2enmod rewrite
sudo service apache2 restart

Debug 4:

Step 1: Log into your server via SSH.
Step 2: Edit your Apache2 configuration file by typing in the following:

sudo nano /etc/apache2/apache2.conf

Step 3: Add the following into your Apache configuration file:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory> 

Step 4: Press “Ctrl + O” to save and “Ctrl + X” to exit Nano.

Step 5: Restart your Apache server by typing in the following:

sudo service apache2 restart

Leave a Reply