【发布时间】:2016-12-20 20:59:19
【问题描述】:
我正在尝试使用此处提供的代码将我的本地 wordpress 安装连接到我拥有的域上的数据库: https://coderwall.com/p/ck8v4a/remote-database-with-local-wordpress-instance
define('WP_CACHE', true); $currenthost = $_SERVER['HTTP_HOST'];
$mypos = strpos($currenthost, 'localhost/wpdir');
if ($mypos === false) {
define('WP_HOME','http://example.org/wpDir/');
define('WP_SITEURL','http://example.org/wpDir/');
} else {
define('WP_HOME','http://localhost');
define('WP_SITEURL','http://localhost/wpDir/');
}
通过上述配置,我可以在本地打开站点,它会正确加载导航和最近的帖子名称,因此 db-connection 似乎可以工作。 我无法使用链接,但找不到页面。
如果我将我的/wpDir/ 添加到define('WP_HOME'... 和/或strpos($currenthost,...,它会被重定向到http://localhost/wpDir/home/(应该如此),但我得到一个找不到 URL 的错误。
我的 localhost 目录是标准的 /var/www/html 这是我的本地 wordpress 安装位置。
任何想法如何解决这个问题?
更新:我将重新开始工作,如果我能够设法使用远程数据库进行本地测试,那将真的很有帮助 我认为这可能是某种 url 重写问题,但我所有寻找解决方案的努力都没有奏效......
【问题讨论】:
标签: php linux wordpress apache ubuntu