Homepage Works but Pages/Posts shows 404 error (apache)

November 28, 2018 1.5k views
Apache WordPress

I’ve successfully migrated to Digital Ocean from Cloudways (was utilizing DO as well).

However, except the homepage every other page shows 404 error. (reference: https://stackoverflow.com/questions/5182534/wordpress-is-giving-me-404-page-not-found-for-all-pages-except-the-homepage)

I’ve looked online and found a couple of solutions:

  1. Change permalinks to default and then back again to your target URL pattern - Didn’t work.
  2. Check your .htaccess file and disable it to see whether that’s what causing the issue - Checked, nothing wrong with that and also WordPress is able to generate a new .htaccess file - so it has the required persmissions
  3. Check your Apache config and ensure that it includes:

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

where AllowOverride should be set to All....

I’ve checked that as well - both vHost file for the domain and the apache2.conf file contains that piece of code.

Am I missing something else? Is there any other way to resolve the error?

Additional Info: When I change my site permalinks to default i.e domain.com/?123 (the defaul URL structure of WordPress) - it works fine. That means, the site has been restored perfectly.

P.S: Installed WordPress manually for this domain and I have virtual hosts configured in a 1-click WordPress ubuntu 18.04 droplet.

1 Answer
ankushdas9 November 28, 2018
Accepted Answer

Got a response from the official DO support:

Replaced my original .htacess content (generated by WordPress) with this and it worked.

# 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

Have another answer? Share your knowledge.