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 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.
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:
define('WP_SITEURL', 'http://newdomain.com/wordpress');
define('WP_HOME', 'http://newdomain.com/');
define('WP_CONTENT_DIR', '/path/to/your/wordpress/wp-content');
define('WP_CONTENT_URL', 'http://newdomain.com/wp-content');
This will force your install to use the newdomain.com
URLs. Also, when you do this the first time set the RELOCATE
setting to true
like this:
define('RELOCATE', true);
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 to false
like this:
define('RELOCATE', false);
But you also say this:
(if WordPress is in a subdirectory should it have a rewrite rule for that instead of just /?)
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:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
To this; note the way I changed the RewriteBase
& the last RewriteRule
:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /coolsite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /coolsite/index.php [L]
</IfModule>
# END WordPress
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With