skip to Main Content

I’m setting up a “local environment” for making some changes on a wordpress site. I have successfully exported the DB and import it on my local using phpmyadmin.
The problem occurs when I try to access “local.wordpress.test” as it takes me straigt to the original www.site.com.

So far, the only thing I’m sure is that this URL is stored somewhere in the DB, and I’m stuck here..

2

Answers


  1. it happen because your database is still pointing your live site url

    just run following query after change following

    OLDURL = your live url
    NEWURL = your local url

    UPDATE wp_options SET option_value = REPLACE(option_value, 'http://OLDURL', 'https://NEWURL') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://OLDURL', 'https://NEWURL');
    UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://OLDURL','https://NEWURL');
    UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'http://OLDURL', 'https://NEWURL');
    UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'http://OLDURL','https://NEWURL');
    UPDATE wp_posts SET guid = REPLACE (guid, 'http://OLDURL', 'https://NEWURL') WHERE post_type = 'attachment';
    
    Login or Signup to reply.
  2. To run your site with live DB in local environment you have to open your DB file in any editor like sublime or notepad or notepad++ then search for your live site url and replace it with your local environment url. you have to replace all urls in your DB with your local url after that import that updated DB in your local phpmyadmin. after successful importing login to your admin panel go to settings-> permalink and hit the save button so it will create a new .htaccess file. hit the local url and your site will work in local.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search