Menu Close

3. Replace live site URL with localhost

If you are moving your live WP website to another web host where you will be using the same domain name, you can skip this next step.
However if you are moving your site to a localhost running on your Mac, there are some additional steps to take. To make your website work on your localhost, we need to change all the reference of the live site domain in the database to the local site domain. In the case of my website,, I have to change all references in the database to http://mysitename.local.

  • We update these references from the live server to the localhost by goingin again to the localhost’s phpMyAdmin. Click on SQL and “Run SQL queryinqueries on database as follows. Copy and paste in a version of the code below that matches your website. Change the references from to ones that match your WP website.
UPDATE wp_options SET option_value = replace(option_value, '', 'http://localhost') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, '', 'http://localhost');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'','http://localhost');
  • Next we need to configure the localhost’s virtual host file. On your local computer, find and edit the httpd-vhosts.conf file located in the MAMP folder on your Mac in the /Applications/MAMP/conf/apache/extra directory, and add the following virtual host entry in it. Then save the file
<VirtualHost mysitename.local:8888>
  DocumentRoot "/Applications/MAMP/htdocs/mysitename"
  ServerAdmin mysitename.local
  <Directory "/Applications/MAMP/htdocs/mysitename">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
  • May not be necessary with MAMP.
    Open the etc/hosts file and add the following entry into it.    mysitename.local