mysql - Xampp 服务器上的 Wordpress — 未定义索引 : host

标签 mysql wordpress

我最近在 Windows 7 上使用 XAMP 在本地设置了 Wordpress。我为我的安装创建了一个 SQL 数据库,并设置了一些配置文件来处理实时服务器和本地,以便在我开始使用 git 时使用。

我有一个wp-local-config.php:

<?php 
// Local server settings

// Local Database
define('DB_NAME', '<mysiteuser>');
define('DB_USER', '<mydbuser>');
define('DB_PASSWORD', '<db password>');
define('DB_HOST', 'localhost');

// Overwrites the database to save keep edeting the DB
define('WP_HOME','/client.dev');
define('WP_SITEURL','/client.dev');

// Turn on debug for local environment
define('WP_DEBUG', true);

还有我的wp-config.php

<?php

// Use these settings on the local server
if ( file_exists( dirname( __FILE__ ) . '/wp-local-config.php' ) ) {
  include( dirname( __FILE__ ) . '/wp-local-config.php' );

// Otherwise use the below settings (on live server)
} else {

  // Live Server Database Settings
  define( 'DB_NAME',     '<live db name>');
  define( 'DB_USER',     '<live db user>');
  define( 'DB_PASSWORD', '<live db pw>' );
  define( 'DB_HOST',     'localhost'  );

  // Overwrites the database to save keep edeting the DB
  define('WP_HOME','http://<client url>');
  define('WP_SITEURL','http://<client url>');

  // Turn Debug off on live server
  define('WP_DEBUG', false);
}

然而,当我登录到我的 wordpress 安装时,我收到很多调试错误,例如:

(在屏幕顶部)

Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1820
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1820
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1876
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1876

在 wordpress new 中:

Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\http.php on line 470
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\class-http.php on line 129

谁能帮我找出为什么会这样?

最佳答案

@Mat-visual:

正如用户 RDrazard 指出的:在您的 wp-local-config.php 中,更改这两行:

define('WP_HOME','/client.dev');
define('WP_SITEURL','/client.dev');

看起来像这样:

define('WP_HOME','http://localhost/client.dev');
define('WP_SITEURL','http://localhost/client.dev');

我用自己在本地安装的 WordPress 对此进行了测试,它清除了您遇到的错误。希望对您有所帮助!

关于mysql - Xampp 服务器上的 Wordpress — 未定义索引 : host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22998169/

相关文章:

python - 尝试安装 mysql-python : "No module named urllib3"

php - 解析错误 : syntax error, 意外 'endif' (T_ENDIF)?

php - 查找特定 WordPress 页面的 url

php - 如何使用wordpress wpdb类插入数据

jquery - 如何在媒体查询中使用 jQuery 最小化列的高度?

wordpress - 如何修复: FB-Pixel detected event code but the pixel has not activated

mysql - 在 mysql json 列中搜索以检查数组同一索引上的多个条件

javascript - 并行运行 Node 和 Apache

java - 在java中将UTC日期和时间添加到数据库

php - MySQL 连接到数据库