Fix – WordPress intermittent 404 error with multiple installation

If you are facing WordPress intermittent 404 error in first page and you are having multiple WordPress under same domain including subdomain or hosted in the same root folder, this is due to path confusion or conflict. You will have to fix this by adding a block of code into the root folder .htaccess file in order to defined the path of each WordPress.


Add the below code into .htaccess in root folder

<IfModule mod_rewrite.c>
RewriteRule . - [E=rwbase:/]
RewriteCond %{HTTP_HOST} localhost$
RewriteRule . - [E=rwbase:yourdomain/]
RewriteCond %{HTTP_HOST}$
RewriteRule . - [E=rwbase:yourdomain/staging/]

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

Example scenario:

  • Main WordPress site folder : localhost/yourdomain
  • Staging WordPress site folder: localhost/yourdomain/staging

Replace yourdomain accordingly to your domain and folder name.


Code Source: