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 have tried copying my wordpress site to my PC for editing offline using WAMP. I followed the following tutorial word for word.

How to create a local copy of a wordpress site

I have placed my files in C:\wamp\www\wordpress

I saw somewhere about adding the following to the wp-config.php but it still points to my website.

define('WP_HOME','http://localhost/wordpress');
define('WP_SITEURL','http://localhost/wordpress');

I am 100% sure that wp_options table in my database only references http://localhost/wordpress so where is it getting my live site address from?

UPDATE 1: I just noticed the following in the bottom of my wp-config.php

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
 define('WP_DEBUG', false);

 define('WP_ALLOW_MULTISITE', true);
 define( 'MULTISITE', true );
 define( 'SUBDOMAIN_INSTALL', false );
 $base = '/';
 define( 'DOMAIN_CURRENT_SITE', 'www.mywebsite.co.uk' );
 define( 'PATH_CURRENT_SITE', '/' );
 define( 'SITE_ID_CURRENT_SITE', 1 );
 define( 'BLOG_ID_CURRENT_SITE', 1 );

 /* That's all, stop editing! Happy blogging. */

 /** Absolute path to the WordPress directory. */
 if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');

 /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

where it says

define( 'DOMAIN_CURRENT_SITE', 'www.mywebsite.co.uk' );

(obviously changed my address for posting) if I change it too

define( 'DOMAIN_CURRENT_SITE', 'localhost/wordpress' );

I get a redirect loop. Is this related or am I changing something I don't need to and the issue is else where?

UPDATE 2: does it having anything to do with the fact that on my website the wordpress files are in the www folder and on the local they are in the www/wordpress folder?

share|improve this question

migrated from stackoverflow.com Aug 5 '13 at 19:15

This question came from our site for professional and enthusiast programmers.

    
Have you modified the database? –  VarunAgw Aug 4 '13 at 11:18
    
As I already mentioned above, yes I have modified the database –  Gaz83 Aug 4 '13 at 12:25
    
You should add http:// to localhost define( 'DOMAIN_CURRENT_SITE', 'localhost/wordpress'; ); –  Joe Buckle Aug 4 '13 at 15:17
    
@JoeBuckle just tried, no difference. –  Gaz83 Aug 4 '13 at 15:40

5 Answers 5

I have found the answer... well to my situation anyway. It was something related to multisite. Removing the following from wp-config.php got it to work for me.

Removed

define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'www.mywebsite.co.uk' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Although I had mine setup for multisite I wasn't really using it so I thought I would try and set it up as single site. As soon as I tried the above it worked.

share|improve this answer
    
Ok. Good that you got the answer. :) –  Mayeenul Islam Aug 6 '13 at 5:43

Try logging in to the local WP installation as an admin. Now go to the dashboard, click "Settings" and change "WordPress Address (URL)" and "SiteAddress (URL)." Make sure you're logging in to the local WP database and not the live one!

share|improve this answer
    
thanks for the reply. I can't login to wordpress. If I type in localhost/wordpress it takes me to my live site www.blahblahblah.co.ukand if I try localhost/wordpress/wp-login.php that too also takes me to my live site. –  Gaz83 Aug 4 '13 at 17:05
    
Right. Well then, I would suggest setting up an Apache virtual host for www.blahblahblah.co.uk. This will force Apache to look for that URL at 127.0.0.1. A Google search should pull up plenty of tutorials on how to do this. –  Neil Girardi Aug 4 '13 at 17:29
    
Thanks for that, I will give it a try now and report back –  Gaz83 Aug 4 '13 at 17:58
    
ok I followed this tutorial link and now I get Error establishing a database connection –  Gaz83 Aug 4 '13 at 20:16
    
Did you set up a local database? If you want to work on a local copy of your WP site you need a local copy of the DB in addition to a local copy of the WP php files. If you have not done this, please so do. If you have done this, please edit your wp config file so that it has the correct credentials to connect to you local DB. –  Neil Girardi Aug 4 '13 at 20:55

I follow an easy process taught by my colleague and teacher Ms. Tahmina Aktar. The process is:

From web server to localhost migration

From the server cPanel File Manager:

  • Step I: Select All the files in your WordPress installation
  • Step II: Compress them into a zip file (.zip).
  • Step III: Download the .zip file into your local server (for WAMP, it's www), and Uncompress it.
  • Step IV: From cPanel's PHPMyAdmin browse the related database, and export all the tables as an .sql file. (i.e. mysql.sql)
  • Step V: Open the mysql.sql file with tables and data into NotePad++ (Because NotePad++ won't make your system lazy or idle even if the db is huge)
    Now press Ctrl + F to Find, and on the text box, type: "http://www.mywebsite.co.uk" and then click on the Replace tab, and type: "http://localhost/mywebsite".
    Now find and replace individually or you can find & replace all.
    And then Save the file mysql.sql.

NOTE: Remember the Forward Slash (/) at the end of the URL. If you typed http://www.mywebsite.co.uk/ in find box, then of course type http://localhost/mywebsite/ in replace box. Otherwise the file structure can be broken, like: mywebsitewp-content/themes/... or mywebsite//wp-content/themes/....

  • Step VI: Make a new database (i.e. my_db) in your local server (i.e. WAMP PHPMyAdmin), and Import the mysql.sql into the db.
  • Step VII: Open the WP-Config.php into your editor, and change the following lines into:

    /** The name of the database for WordPress */
    define('DB_NAME', 'my_db');

    /** MySQL database username */
    define('DB_USER', 'root');

    /** MySQL database password */
    define('DB_PASSWORD', '');

    (or the settings you have in your localhost)

    Save the file and Browse your site in localhost freely.


From localhost to web server migration

If you need to launch your site to the web from the localhost, just follow the procedure alternatively.


Let's talk about your problem:
Now, you got the idea how you can manage your database for local server and remote server simply by replacing the relative URLs in correct form and directory path. So, you can search your db in NotePad++ if there is any web related mentions there, you need to replace.

Good luck. :)

share|improve this answer
    
That's basically the same as the tutorial that I followed –  Gaz83 Aug 5 '13 at 20:30
    
Try the whole thing again. I think you made an unwanted mistake anywhere. Or, confirm that, there is nothing like the word "mywebsite.co.uk" (you know it's not as it is mentioned) is not present in your db. –  Mayeenul Islam Aug 6 '13 at 5:41

My suggestion is download all your files associated with site as a zip and extract to localhost.

Add a plugin named wp-migrate. http://wordpress.org/plugins/wp-migrate-db/ ativate it.

Go to Tools -> Migrate DB

Enter your localhost url in the place of new address.No '/' required at the end.

New file path as the path in local system: eg: D:\wamp\www\

Click on Export Database.

Create a database and import the sql that your exported using the plugin to the created database.

Change the host, databasename, db username and dbpassword in wp-config file.

Hope this will help you. Thank you :-)
share|improve this answer

I just had the same exact issue, add a / to the end of your site url and home in your config and database, also check for whitespace at the end of your config file and remove it.

share|improve this answer

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.