WordPress―move from domain.com to localhost/dir

I have a wordpress multisite installation which would like to move from the productive domain to my localhost, so the the installation should be altered in a way that somedomain.com becomes localhost/dirname.

Right now I have these settings in wp-config.php:

Read More
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'localhost' );
define( 'PATH_CURRENT_SITE', '/dirname/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
define( 'SUNRISE', 'on' );

and the .htaccess looks like:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]

Right now an infinite redirect loop starts to: http://localhost/dirname/wp-signup.php?new=localhost

Which settings do I have to make?

Greetings,
philipp

EDIT

If WP_ALLOW_MULTISITE and MULTISITE is set to false this problem does not occur, but since I need to access the page as multisite this is no option.

Related posts

Leave a Reply

3 comments

  1. If you’re moving a wordpress installation, after importing the database into your local mysql server. Edit your wp-config.php file, changing the ‘DB_NAME’ ‘DB_USER’ ‘DB_PASSWORD’ ‘DB_HOST’ to reflect the settings for your local database. Then use this script http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to search for your domain name and replace it with localhost/dirname. After that you login and save your permalinks.

  2. Hope it helps.

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
    RewriteRule . index.php [L]
    
  3. JUst checked, to install WordPress MU in localhost on subdomain/subdirectory, you need to set up virtual hosting in Windows system.

    Go to C:WINDOWSsystem32driversetc and open the file “hosts” with notepad (you need to have administrator privilege to edit the file. Right click the Notepad application in the Start menu and select Run As Administrator).

    Insert in the line

    127.0.0.1 localhost.localdomain

    to the end of the file. Save and close the file.

    If you are using mac os, you can follow this http://wpdreamer.com/2013/08/how-to-setup-a-localhost-wordpress-sub-domain-multisite-environment/

    You could change it to localhost.com, then edit your wp-config file to reflect that, also change the values in the database using http://interconnectit.com/products/search-and-replace-for-wordpress-databases/