【问题标题】:WordPress Migration to subdomain corrupted by incorrect pathWordPress 迁移到因路径错误而损坏的子域
【发布时间】:2016-03-16 04:02:43
【问题描述】:

我正在开展一个项目,该项目涉及将 WordPress 安装从 A 点迁移到 B 点。这应该相当简单,但是手动或基于插件的传输都不起作用。解释:

A 点是“demo.com”的一个相当标准的安装,我正在尝试将它迁移到一个子域(B 点),比如“c.example.com”。当然,我可以很好地迁移代码、插件、主题等,但是当我带来数据库时,一切都变得混乱(并且我已经更新了站点 URL / 主页 URL / 数据库中的一些永久链接结构)。

<head> 标记内的一段代码显示了一些有趣的信息:

<link rel="stylesheet" id="parent-style-css" href="http://c.#wp-content/themes/Example_theme/style.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="style-css-css" href="http://c.#wp-content/themes/Example_theme/style.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="layout-css" href="http://c.#wp-content/themes/Example_theme/css/layout.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="main-css" href="http://c.#wp-content/themes/Example_theme/css/main.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="shortcodes-css" href="http://c.#wp-content/themes/Example_theme/css/shortcodes.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="mediaelement-css" href="http://c.#wp-includes/js/mediaelement/mediaelementplayer.min.css?ver=2.18.1" type="text/css" media="all">
<link rel="stylesheet" id="prettyPhoto-css" href="http://c.#wp-content/themes/Example_theme/css/prettyPhoto.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="responsive-css" href="http://c.#wp-content/themes/Example_theme/css/responsive.css?ver=4.4.2" type="text/css" media="all">
<link rel="stylesheet" id="instag-slider-css" href="http://c.#wp-content/plugins/instagram-slider-widget/assets/css/instag-slider.css?ver=1.2.1" type="text/css"

仔细看,你可以看到href/path不包含'example.com'域名,而是用“#”代替。

http://c.#wp-content/themes/Example_theme/css/responsive.css?ver=4.4.2

进一步说明,我已更新 wp-config 文件以定义 WP_HOME 和 WP_SITE URL,但这没有任何效果。 .htaccess 也针对子域进行了更正(另外没有效果),它显示:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /c/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . //index.php [L]
</IfModule>

# END WordPress

原因似乎是在数据库中的某个地方,但是可能有一个文件在某个地方控制它。

欢迎任何帮助,非常感谢。

再次感谢您抽出宝贵时间解决我的问题。

【问题讨论】:

    标签: mysql wordpress .htaccess config


    【解决方案1】:

    首先,从头开始尝试。清理所有子域文件和数据库。然后,将所有 example.com 文件复制到子域。之后,导出所有 SQL 数据库(与 wp 安装相关)并导入到子域的数据库中。

    之后编辑 wp-config.php 并将相关信息放在这些行中:

    define('DB_NAME', 'your_db_name');
    /** MySQL database username */
    define('DB_USER', 'your_subdomains_db_user');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'your_subdomains_db_pass');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    ...
    
    $table_prefix  = 'your_subdomain_db_table_prefix';
    

    在操作之后使用这个脚本https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

    您需要做的就是将它复制到您的子域中,访问它的主文件并使用它将“example.com”的所有数据库条目替换为“c.example.com”。

    就是这样,之后您应该在您的子域中拥有 example.com 的功能齐全的 WP 副本。

    另外,您可以阅读法典以获取更多信息https://codex.wordpress.org/Moving_WordPress

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 2018-09-13
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      • 2013-08-14
      • 2012-03-25
      相关资源
      最近更新 更多