Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter helbetica

    (@helbetica)

    Dear WP Developer Diary
    LOL, just kidding!

    Hi everyone
    So far, I’ve done these steps and my attempt failed:

    – donwloaded remote DB
    – imported remote db to my http://localhost/phpmyadmin/ (same name)
    – created same remote db user at localhost phpmyadmin, and GRANTed priviledges
    – backed up my local wp-config.php file (pointing to the original working db)
    – updated wp-config.php variables to reflect the remote settings:
    define(‘DB_NAME’, …
    define(‘DB_USER’, …
    define(‘DB_PASSWORD’, …
    define(‘DB_HOST’, ‘localhost’);
    define(‘DB_CHARSET’, …

    – created the wp-content/db.php (below the code)

    <?php
    
    // paste this in a (new) file, wp-content/db.php
    add_filter ( 'pre_option_home', 'test_localhosts' );
    add_filter ( 'pre_option_siteurl', 'test_localhosts' );
    function test_localhosts( ) {
    	// intercept these options
    	if ($option == "siteurl" || $option == "home") {
    
    		// test localhost
    		$http_host = $_SERVER['HTTP_HOST'];
    		echo $http_host;
    		if (strpos($http_host, 'localhost') !== false) {
    		    return "http://localhost:8080/my-local-website/_wordpress/";
    		}
    
    	}
    	else return false; // act as normal; will pull main site info from db
    }

    So far attempt failed!
    Localhost wp copy redirects me to remote wp site.
    Tested php strpos function on a different file and return true on checking if my server HTTP_HOST has the string/word ‘localhost’ on it

    Any help, it will be kindly appreciated!
    Tks

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Take a look at http://versionpress.net

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Two WordPresses, One Database’ is closed to new replies.