Page Not Found Error 404 – Staging Site Redirects to Production Site

If you created a staging site with WP Staging and accessing the staging site redirects you back to the production site, you have several options that you can try out first to solve that issue:

Activate post name permalink settings on the staging site

When you are on the staging site and clicking a link redirects you to the live site, try to activate the permalink settings on the staging site and make it identical to your production website’s permalink settings.

As a default, WP Staging sets the permalink settings to the default plain type, so switching this setting will often resolve any link redirect issues.

Read more: How to Activate WordPress Permalinks.

Use absolute URLs instead of relative ones.

Check out the structure of a link that redirects back to the production website.

WP Staging cannot search & replace over relative links, so it will need absolute links on your site to do an automatic search & replace through it.

So, for instance:​

Working link:
Not working link: /path-to-page

​To resolve it, you have three options:

  • A. Create a new staging site and use a subdomain for it. Then, relative links have no negative side effects and will work as intended.
  • B. Use absolute URLs instead of relative links.
    Convert all relative links​ to absolute ones. Do this first on the live site and then clone again or change the staging site’s links after creating the staging site.
  • ​C. Ignore non-working relative links and open the admin dashboard pages if you want to edit them.

    The recommended way is either option `A` or `B` as it makes working on the staging site much easier than needing to open all the pages for editing from the admin dashboard.

Remove or edit the .htaccess

When you create a clone of your website into a subfolder, WP Staging removes the .htaccess on the cloned site.

The reason is WordPress uses the .htaccess that is located in the root folder of your production site. If one of your plugins recreates the `.htaccess` file on the staging site, it could be that that file overwrites the rewrite rules, resulting in non-working permalinks on the staging site.

If that’s the case, rename the `.htaccess` located in the staging site to something else like `.htaccess-disabled` and try again accessing the staging site. For renaming the file, you can use your FTP client, cPanel file manager, or you can use a file manager plugin installed on your production site.

Bitnami htaccess settings

If you use WordPress in a Bitnami instance, you need to take extra steps.

Post-name permalinks are not supported out of the box on WordPress Bitnami instances because Bitnami does not use .htaccess in the website’s root folder. It ignores any .htaccess file there.

Bitnami does not use the default .htaccess file in the root of your website; instead, all the htaccess configurations are added to a file called: /opt/bitnami/apps/APPNAME/conf/htaccess.conf.

So if you want to make permalinks working, you will need to modify the htaccess.conf

Go to that file and add the following to it:

<Directory /opt/bitnami/apps/wordpress/htdocs/STAGING>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /STAGING/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /STAGING/index.php [L]

Rename the word STAGING to the folder name of your staging site.

Another option would be to keep the permalinks on the plain settings. Then you do not need to change the htaccess.conf at all.

Clone to a Subdomain

If you are not able to solve the redirection issue, you can clone your WordPress website to a subdomain and another folder by using the custom target path and hostname option of WP STAGING Pro:

We have written an extensive guide on how to clone your WordPress site to another subdomain:

Use of Language Plugins like WPML or Polylang

If you use a language plugin like Polylang or WPML that adds a language slug to the URL, for instance, https://
you will need to activate the post name permalinks on your staging site.

Otherwise, this could be another reason for a link redirect to live.

Disable Security & Login Plugins on Staging Website

Create a new staging website and disable all these plugins by excluding the plugin folders from the cloning process:

  • Security plugins like Wordfence, iThemes Security, Cerber, WP Spamshield, etc.
  • Caching plugins like W3 Total, WP Rocket, etc.
  • Language plugins like WPML, Polylang (Or activate permalinks on the staging site)
  • Redirection or “Hide my Login” plugins

If you already created a staging website and you retrospective need to disable those security plugins, you can disable certain plugins by renaming their plugin folder via FTP or any file manager plugin.

For instance, you can disable the WP Spamshield plugin by renaming the plugin folder stagingsite/wp-content/plugins/wp-spamshield to something else.

Disable Redirect Plugins on the Staging Site

Some plugins can cause such redirects, like specific redirect plugins, membership plugins, or SSL plugins that redirect HTTPS when you open your site from an HTTP endpoint.

A few examples of those plugins are:

If you use one of these plugins on your staging site, create a new staging site but exclude the particular plugin from the cloning process.

Alternatively, you can disable and deactivate the redirect causing plugin on your staging site by renaming its plugin folder to something else like
/wp-content/plugins/plugin-name-disabled. To do so,  login to your staging site with FTP and rename the particular plugin folder to something else.

Does it still redirect you to the production website?

If it does not resolve the issue, please open a support ticket, and we assist you in resolving the redirect issue.

Updated on December 18, 2020