I’m working on some edits for a client’s site. So I downloaded the site’s files and exported the database.
I need to make some big changes on a development machine first so I won’t mess with the live site.
Then I imported the database to my development machine and setup the files as well. But whenever I go to http://localhost it redirects me to the client’s site:
https://theclientsite.com
So since it redirects me to a https address I’m thinking it probably has something to do with that.
I did a global search on the code for the client’s domain, but I don’t see anything that redirects.
What could be the source of the redirecting? If the site doesn’t stop redirecting, I can’t work.
Usually, this is a problem with the Site URL or WordPress URL not being set properly. If you just copied the database, WordPress itself will try to redirect the domain back to what it thinks is the right site.
You have two options:
1. Edit the Settings
Use PHPMyAdmin or a similar tool to edit the site url and WordPress url settings in the database. This should fix the problem assuming nothing else on your development box is forcing the redirect.
2. Change your Hosts File
This is the better solution. Edit your hosts file to point
http://clientsite.com
at your local IP address (127.0.0.1). Then, just navigate to the development site the same way you would the production site. Just remember to change your hosts file back when you’re done developing.I concur with EAMann that it is probably database-related. I, however, think the first solution is better than the second of the two provided. When I move WordPress installations (usually from development to production rather than the opposite, like you), I simply run a few UPDATE statements in phpMyAdmin. This is what I run:
Make sure you edit the URLs and table names according to your situation.
If you’re into wp-cli.org this will do the trick in many cases:
Or if you’re on
localhost
: