How do I stop a WordPress staging site from redirecting to the live domain?
#1
I’ve been trying to set up a staging site for my main WordPress installation, but every time I copy the database over, it still tries to connect to the live domain. I’ve updated the site URL in the wp-config file and ran a search and replace on the database, but I must be missing a step because it keeps redirecting.
Reply
#2
Yeah, I know the feeling. I copied the DB and the site kept loading the live URL. I updated the SITE_URL and HOME in the options table and did a search and replace, but the redirect kept happening.
Reply
#3
Check for a hard redirect somewhere on the server like .htaccess or hosting redirect rules. Sometimes the staging domain is wired to forward to the live one and you only notice after a while.
Reply
#4
Cache matters here. I cleared the server cache, purged the CDN, and even asked my browser to forget the old redirect, and it still showed the live domain at first.
Reply
#5
A plugin or theme can rewrite URLs on the fly. I started by disabling plugins on the staging copy and that helped isolate the issue a bit.
Reply
#6
If you defined WP_HOME or WP_SITEURL in the config, make sure they actually match the staging URL rather than the live one. I ran into a mismatch that kept sending me back.
Reply
#7
Are you sure the request is actually hitting the staging host, and not a DNS or hosts file mapping? It felt like it until I double checked the network path.
Reply
#8
One more thing I learned: serialized data can keep the old URL after a naive search and replace. If you’re seeing stubborn leftovers, you might need a tool that handles serialized values instead of plain string replace.
Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump: