WordPress 链接全部重定向到双 URL
一位开发人员在他的本地机器上建立了一个 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.
相关文章