Copy online WordPress blog to localhost

Before we start lets define a few things for this example:

  1. The hosted version address we will refer to as: (This is the web address of the hosted wordpress site)
  2. The local version address we will refer to as: http://localhost/testsite (This is the web address of the local host folder you want to transfer your site to)

Copy your files from your webhost to your local server folder.

On your webhost login to phpmyadmin and export your database (By Selecting your database and selecting the export tab and downloading to your computer)

Log into your local phpmyadmin, create a new database and import the sql database into it by selecting the import tab and uploading your file.

Once Uploaded we want to modify the database to reflect the new blog location being on the localhost. So we run the following SQL (Select the SQL tab and paste the following code):

UPDATE wp_options SET option_value = replace(option_value, '', 'http://localhost/testsite') WHERE option_name = 'home' OR option_name = 'siteurl';

Note : 

You can change them in the wp-config and not use sql ( but sql better ) 

// define(‘WP_HOME’,’http://localhost/ithireorg’);
// define(‘WP_SITEURL’,’http://localhost/ithireorg’);

We now want to fix the urls of posts and pages. So we run the following SQL:

UPDATE wp_posts SET guid = replace(guid, '','http://localhost/testsite');

If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. So we run the following SQL to fix this issue:

UPDATE wp_posts SET post_content = replace(post_content, '', 'http://localhost/testsite');

We want to now modify our wp-config.php file in our local server. Honestly, the easiest way to do this is to delete the wp-config.php file in your local server and then visithttp://localhost/testsite in a browser.

With the dialog message that comes up click the ‘Create a Configuration File’ button. Then click the ‘Lets Go’ button on the next screen.

Fill in all of the fields:
Database Name: This is the name of the database in your local phpmyadmin
Username: This is your phpmyadmin username (usually root)
Password: This is your phpmyadmin username’s password
Database Host: This is usually localhost
Database Prefix: normally is wp_ unless someone has changed it manually.

STEP 10:
Click Submit, the wp-config file will be created and everything should work on the local host.
STEP 11:
There is problem about the permalink you need to change the permalink to default again in orderthat the link work fine .


To make the permalink work fine if you made custom permalink .. you have to enable mod_rewrite .. you can find it in the http.conf  and finally the problem solved

also make sure the .htaaccess file have the RewriteEngineOn .

the other way : 

Use the wordpress plugin duplicator to make that


And here is the final way to solve this problem : 

note : this is just an example

  • Make the database name and import the tables to the database
  • Only get the content folder from the wordpress website ( that all you want here )
  • get new copy for wordpress in the localhost .
  • and then make sure you enable mod_rewrite in http.conf ( IMPORTANT ) 
  • you have to change the .htaaccess file to the right directory

RewriteBase /directoryname/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directoryname/index.php [L]

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: