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.
So now hereâs whatâs happening.
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
the .htaccess
file is all default, (if WordPress is in a subdirectory should it have a rewrite rule for that instead of just /?)
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?
UPDATE:
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.
I Solved it! Hopefully if anyone else comes here and has the same mistake, this will help. In the
wp_options
table the rows forsite_url
andhome
need to havehttp://
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.While doing the database adjustments you did might work, I find them to be problematic. Instead whenever one moves a WordPress site, you need to properly adjust configurations in your WordPress install in the
wp-config.php
file on the following variables:This will force your install to use the
newdomain.com
URLs. Also, when you do this the first time set theRELOCATE
setting totrue
like this:That basically tells WordPress to rejigger (thatâs my technical term for it) itâs stored settings for the new settings. And after you have reloaded your site & it works as expected, set
RELOCATE
setting back tofalse
like this:But you also say this:
That has to change if you are placing WordPress in a subdirectory. So letâs assume that WordPress is in a subdirectory called
coolsite/
. Then change the default WordPress.htaccess
from this:To this; note the way I changed the
RewriteBase
& the lastRewriteRule
:Put
http://
in front ofsite_url
andHome_url
in thewp_option
table of your database.