Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Is there any evidence that this redirect is WordPress related? –  Chip Bennett May 9 '12 at 20:07
    
I asked my client if he installed any plugin that would do that and he said no. –  leonel May 9 '12 at 20:10
    
there is no .htaccess file either –  leonel May 9 '12 at 20:10
add comment

2 Answers

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.

share|improve this answer
    
just edited the database for both the siteurl and home options. i'm going to try the hosts file solution now –  leonel May 9 '12 at 20:26
    
ok, i edited my hosts file and it did work, the site is not redirected anymore, but now the links don't work, i can only see the homepage. i know it has something to do with permalinks because i go to domain.com/tour and i get a 404 not found error –  leonel May 9 '12 at 20:59
    
The first solution sounds like the best one here. Editing your hosts file for dev if it's not necessary can cause confusion about which version you're actually viewing at any given time. If you're not careful, it may even cause you to make configuration changes on production when you think you're editing locally :S Plus, you have to re-edit your hosts file, clear your DNS cache, etc to switch view different deployment states, which can be a hassle. –  MathSmath May 9 '12 at 21:56
1  
@leonel Sounds like you're missing your .htaccess file. Make sure it's in the site's root, and that it has the "pretty permalink" rewrite rules in it. –  MathSmath May 9 '12 at 21:57
    
If you're getting 404s from that kind of link, you're missing .htaccess Log in and navigate to the Permalinks page and WP should auto-generate the file. –  EAMann May 9 '12 at 23:14
show 2 more comments

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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