WordPress on localhost still points to the live site

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

Read More

I have placed my files in C:wampwwwwordpress

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?

Related posts

6 comments

  1. 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.

  2. Update

    Instead of find-replace string using Notepad++ (or any editor) a better way would be to use a plugin which does the same job in a safer way — a way where the serialized data would be intact during the migration:

    Use plugin like the Velvet Blues Update URLs. The plugin can be used for migration from localhost to live server or vice versa. Josh Hall has a video on that:

    🎬 Video: How to MANUALLY Migrate Your WordPress Site – Josh Hall


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

    From webserver 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 a .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 the 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 of how you can manage your database for the local server and the remote server simply by replacing the relative URLs in the correct form and directory path. So, you can search your DB in NotePad++ if there are any web-related mentions there, you need to replace.

    Good luck. 🙂

  3. 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!

  4. 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:wampwww

    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 :-)
    
  5. 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.

  6. For a multi-site setup check your wp_blogs table. The domain field there likely contains a reference to your live site and is the culprit.

Comments are closed.