1

I have two wordpress site one in main directory (public_html) and another one is in subdirectory staging. I already configure all the settings in subdirectory site with http://example.com/staging but when I load http://example.com/staging it redirect to Page Not Found in main site and not in staging site. I set the .htaccess file in staging subdirectory like this.

# BEGIN WordPress
<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]
</IfModule>

# END WordPress

And this in on the main site in main directory.

# 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

Anybody can help me with this issue and my staging site can load properly ? Thank you before.

1

There are some things you can try:

  • Check the wp-options table in your staging site database and look for site URL in 2 places. Change it to the correct staging address if already not.
  • Refresh the permalinks of the staging site.

I am guessing this should fix your problem. If not, please share your website address.

P.S. If both the sites (main and stage) have the same content, you might wanna add a robots.txt file in the staging instance just to be safe from being considered as duplicate content.

  • I already change site URL and home with correct url in wp-options and how to refresh permalinks if I cannot open and login to wordpress dashboard ? – Antonio Nov 23 '17 at 6:31
  • And for the main and staging yes it's have same content. How to add robots.txt file in staging ? – Antonio Nov 23 '17 at 6:33
  • ok. lets worry about the robots file later. Check your wp-config.php file for correct DB details. What is the result of example.com/staging/wp-login.php? Is it redirecting to the main domain? – Sid Nov 23 '17 at 6:36
  • Yes in wp-config.php the DB details is correct. And, example.com/staging/wp-login.php yes it gives me redirecting to the main domain page not found. – Antonio Nov 23 '17 at 6:40
  • ok try this one, open the index.php for your staging site (the one inside WordPress not in theme folder), find the line require( dirname( FILE ) . '/wp-blog-header.php' ); and change it to require( dirname( FILE ) . '/staging/wp-blog-header.php' ); Let me know the results. – Sid Nov 23 '17 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.