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 would like to redesign my wordpress site. I thought I do that first locally to get a feeling for it. So I compressed my live wordpress directory and transfered it locally. And took a backup of the database and transfered it locally as well.

I restored from both files the exact copy of my live wordpress on my lcoal machine. Going to 127.0.0.1 works fine. But all the links still point to my BlogSite.com rather than 127.0.0.1.

Is there any quick "fix" for that? Or any other strategy how I could achieve working locally on my website?

Thanks,

share|improve this question

3 Answers 3

You may first need to modify the wp-config.php file for using the local database.

Then use the Search and Replace plugin to replace all your live site links with the localhost links. Example: If your live site url is: http://mysite.com/, replace it with http://localhost/mysite/. This will also replace the urls for pages and posts like: http://mysite.com/post with http://localhost/mysite/post.

Note: You'll still need to manually update any links (and image urls) in the widgets, because S and R doesn't replace them.

share|improve this answer
    
Thanks, I have named the localdb like my live site, so there was no need to edit wp-config.php. I searched and replaced the site reference in the sql dump. But permalinks dont seem to work yet... –  Kave Jun 18 '12 at 10:55
    
That's because the manual search and replace doesn't work completely! All the urls stored in the wp_options table are searialized, and a manual search and replace won't change them! Upload your sql dump again, and use the plugin I mentioned above. –  Rutwick Gangurde Jun 18 '12 at 11:00
    
I have reuploaded my dump file without any changes. Then I installed wordpress.org/extend/plugins/search-and-replace. Did teh search and replace in there. It still doesnt work. :( –  Kave Jun 18 '12 at 11:14
    
Not even the login? –  Rutwick Gangurde Jun 18 '12 at 11:35
    
login is working :) –  Kave Jun 18 '12 at 11:38

You should replace all occurences of live website for the local path in your DB dump and in template files (if there are any hardcored urls, i hope not ;) ). Moving WP from server to server goes quite fine, I always copy everything from FTP, then do the database dump (*.sql file for example, you can use for instance phpmyadmin or whatever you prefer), replace all urls for the local ones, import this file in your local DB and change wp-config.php to use correct database settings. So having a "snapshot" of live page can be done in a few minutes.

share|improve this answer
    
Thanks I have exactly done that. But permalinks doesnt seem to work. the .htaccess is still inside my /var/www/mySite so why doesn't it work? –  Kave Jun 18 '12 at 10:53
    
so try to go to Options page in WP admin and rebuild all permalinks structure, if it helps? –  Karel Attl Jun 18 '12 at 10:56
    
ok, I went to WpAdmin -> Settings --> Permalinks and saved it as it was. It saved. I go back to homepage and do refresh. Still all permalinks broken. Any other tip? :) –  Kave Jun 18 '12 at 11:00

You may also want to add a line in your /etc/hosts file, like this:

1.2.3.4 www.myblog.example.org

The first line should be the IP of tour TEST machine, the second one is your blog's DNS name.

After adding this line in /etc/hosts "everyone" in your test machine will "know" that www.myblog.example.org is at 1.2.3.4.

You need to change nothing in the database or wordpress settings.

And you can comment/uncomment this line at any time.

share|improve this answer
    
This seems indeed like a clean alternative. No need to mess around with the dump file. While this solution in it self work, the permalink problem is still there. :( –  Kave Jun 18 '12 at 14:16
    
@Kave There should not be any issue with permalinks. Check apache's settings, installed/enabled modules, httpd.conf etc. If you "clone" everything (apache, WP, wpdb, settings etc-etc), you should get the same box, a "clone". A line in /etc/hosts simply "workarounds" resolver's behavior. This way works for me perfectly. –  brownian Jun 18 '12 at 18:20

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.