WordPress subpages give 404 error

If you have a Wordpress website and are experiencing 404 errors on all pages except your homepage and your admin area, then it's probable that your .htaccess file is missing the necessary Wordpress configuration. 

To resolve this, perform the following steps:

  • Log in to your cPanel and visit the File Manager
  • Enable viewing hidden files
  • Visit the folder that contains your Wordpress installation. If this is for your primary domain, that would probably be /public_html
  • Open your .htaccess file, or if it does not exist, create one named ".htaccess" (no quotations)
  • Insert the following code into your .htaccess file, below any existing code:
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
  • Save the file and then reload your website. It should now work.