Keeps on redirecting on my development copy

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.

Read More

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.

Related posts

Leave a Reply

3 comments

  1. 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.

  2. 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:

    update wp_posts set post_content = replace(post_content,'development.org','production.org');
    update wp_posts set guid = replace(guid,'development.org','production.org');
    update wp_options set option_value = replace(option_value,'development.org','production.org');
    update wp_commentmeta set meta_value = replace(meta_value,'development.org','production.org');
    

    Make sure you edit the URLs and table names according to your situation.