我嘗試連接我的本地安裝WordPress對我自己使用的代碼域分貝此處提供: https://coderwall.com/p/ck8v4a/remote-database-with-local-wordpress-instance本地WordPress的使用遠程數據庫,Ubuntu的,的Apache2
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連接似乎工作。 我無法使用鏈接,但頁面未找到。
如果我加我/wpDir/
到define('WP_HOME'...
和/或strpos($currenthost,...
它被重定向到http://localhost/wpDir/home/
(因爲它應該),但我得到沒有找到URL錯誤。
我的本地主機目錄是標準的/var/www/html
這是我本地wordpress安裝的地方。
任何想法如何解決這個問題?
更新:我回到了這個工作,它會真的幫助很多,如果我能設法使用遠程數據庫爲我的本地測試 我認爲這可能是某種URL重寫問題,但我所有的努力找到一個解決方案沒有奏效...