問題描述
一位開發人員在他的本地機器上建立了一個 WordPress 網站.然后他將整個安裝遷移到服務器上.自然,sql中的所有鏈接都設置為localhost:8888
.然后我運行了一個 SQL 更新來修復鏈接,使它們指向正確的域(現在是一個 ipaddress/~username
鏈接).我已經仔細檢查了我的工作,一切看起來都是正確的.
A fellow developer built a WordPress website on his local machine. He then migrated the whole installation onto a server. Naturally, all the links in sql were set to localhost:8888
. I then ran a SQL update to fix the links so they pointed to the correct domain (which right now is an ipaddress/~username
link). I've double checked my work, and it all looks correct.
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_options SET option_value = replace(option_value, 'feed://www.olddomain.com', 'feed://newdomain.com');
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
我使用了該編碼,但其中包含適當的域信息.
I used that coding, but with the appropriate domain information in there.
現在是發生了什么.
每當我進入主頁時,它都可以工作,但圖像不顯示.然后我點擊一個鏈接,或前往 wp-admin,它在 urlbar 中顯示了兩次 url.所以它會變成這樣:
Whenever I go to the homepage, it works, but the images don't show up. then i click on a link, or travel to teh wp-admin, and it shows the url twice in the urlbar. so it goes to something like:
http://newdomain.com/~user/http://newdomain.com/~user/post-name-blah-blah-blah
.htaccess
文件都是默認的,(如果 WordPress 在一個子目錄中,它應該有重寫規則而不是/?)
the .htaccess
file is all default, (if WordPress is in a subdirectory should it have a rewrite rule for that instead of just /?)
如果沒有像 SQL 中那樣列出,什么會導致網站上的每個鏈接兩次訪問同一個 URL?
What could cause every link on the site to go to the same url twice, if none of them are listed like that in SQL?
更新:
好的,所以我刪除了整個數據庫并重新設置,然后站點就可以正常工作了.當然,這意味著我丟失了所有內容.我猜我在某處搞砸了 sql 查詢.但是我找不到任何有兩個 url 的地方,或者甚至會導致這種情況.隨著我發現我的問題,將會有更多更新.
Alright, so I erased the whole database and reset that up, and then the site works fine. of course that means I lose all my content. I'm guessing i screwed up the sql query's somewhere down the line. But I can't find anywhere that has two urls, or would even cause this. More updates coming as I figure out my issue.
推薦答案
我解決了!希望如果其他人來到這里并犯了同樣的錯誤,這會有所幫助.在 wp_options
表中,site_url
和 home
的行需要在它們前面有 http://
.不知何故,我的 sql 查詢破壞了該部分.我當然沒有注意到,因為地址看起來是正確的,因為這通常有效.但在這種情況下,它會導致一些鏈接永無止境的循環,而在其他情況下,它只會將地址翻倍.
I Solved it! Hopefully if anyone else comes here and has the same mistake, this will help. In the wp_options
table the rows for site_url
and home
need to have http://
in front of them. Somehow on my, my sql query busted that portion. Of course I didn't notice because the address looked correct, because that normally works. but in this case it caused a never-ending loop with some links, and in others just doubled the address.
這篇關于WordPress 鏈接全部重定向到雙 URL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!