在本地主机上设置多站点后,对本地主机的请求重定向到生产域

时间:2015-01-23 作者:Leftium

在上设置多站点后http://localhost, 请求发送至http://localhost 重定向到http://production-domain.com (包括“登录”)。

生产域信息甚至从何处检索

Log In is also affected:

<多站点前:加载http://localhost/wp-admin/http://localhost/wp/wp-login.php?redirect_to=http://localhost/wp/wp-admin/&reauth=1
  • (登录页面样式正确。)http://localhost/wp-admin/http://www.production-domain.com/wp-login.php?redirect_to=http://localhost/wp/wp-admin/&reauth=1
  • (登录页面缺少样式,因为css无法从加载http://www.production-domain.com.)
  • <人力资源>

    How I configured multisite.:

    Added following lines to c:/www/wp/wp-config.php:

    define( \'WP_ALLOW_MULTISITE\', true );
    
    define(\'MULTISITE\', true);
    define(\'SUBDOMAIN_INSTALL\', false);
    define(\'DOMAIN_CURRENT_SITE\', \'localhost\');
    define(\'PATH_CURRENT_SITE\', \'/\'); // Also tried: define(\'PATH_CURRENT_SITE\', \'/wp/\');
    define(\'SITE_ID_CURRENT_SITE\', 1);
    define(\'BLOG_ID_CURRENT_SITE\', 1);
    

    (Already had this in /www/wp/wp-config.php:)

    // Overwrites the database to save from constantly editing the DB
    define(\'WP_HOME\',\'http://localhost/\');
    define(\'WP_SITEURL\',\'http://localhost/wp\');
    

    c:/www/.htaccess:

    # Original version left as comments at bottom.
    # Note WordPress is installed in the wp subdirectory
    # so there is another file, c:/www/wp/.htaccess
    # which I have tried both editing and leaving intact.
    
    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\\.php$ - [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).*) wp/$2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ wp/$2 [L]
    RewriteRule . index.php [L]
    
    # <IfModule mod_rewrite.c>
    # RewriteEngine On
    # RewriteBase /
    # RewriteRule ^index\\.php$ - [L]
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule . /wp/index.php [L]
    # </IfModule>
    #
    # # BEGIN WordPress
    # <IfModule mod_rewrite.c>
    # RewriteEngine On
    # RewriteBase /wp/
    # RewriteRule ^index\\.php$ - [L]
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule . /wp/index.php [L]
    # </IfModule>
    #
    # # END WordPress
    

    1 个回复
    SO网友:Leftium

    好啊我想出来了:When moving to multisite, manually overriding WP_HOME and WP_SITEURL like below doesn\'t work anymore:

    // Overwrites the database to save from constantly editing the DB
    define(\'WP_HOME\',\'http://localhost\');
    define(\'WP_SITEURL\',\'http://localhost/wp\');
    
    我通过手动更改数据库修复了此问题,因此WP\\u HOMEhttp://localhost WP\\u SITEURL为http://localhost/wp.

    结束