tonybaldwin
tonybaldwin

Reputation: 171

siteurl change in wordpress ( changed in DB), but links still pointing to prior url

I have a Wordpress installation for a client, and she's changed her domain name. Because the former domain reg lapsed, I can no longer access any part of the site from its former domain, so I changed the vhost, to a subdomain of one of my domains to access it for now, but can only get its homepage, all the menu links are going to some spammy advertisement now parked on her former domain. So I went into Maria DB and updated siteurl in the wp_options tableto the new subdomain, but nothing has changed, still being linked to the spammy parked ads from any of the links on the site's home page, even site.tld/wp-admin.php and site.tld/wp-login.php. Is there, since I can't access the online/gui admin stuff, somewhere else in the DB where I can or need to change something to update ALL internal links to function on the new domain? The WP hasn't been updated since before the domain lapsed several months ago (client doesn't pay, I don't update domain reg... Any and all assistance appreciated in advance. Thanks, Oh...I'm using MariaDB on Debian Jessie...or wait, the server is still running wheezy.

Upvotes: 0

Views: 1314

Answers (3)

BonisTech
BonisTech

Reputation: 431

Try using the wp-cli. Go to your WP root folder in your terminal and run the following command:

wp search-replace "old-domain.tld" "new-domain.tld"

If it's a multisite installation, use the flag --network

This should replace all the existing urls in your database.

You can also add the flag --dry-run to see a report about what's happening without saving changes to your database.

For more info: https://developer.wordpress.org/cli/commands/search-replace/

Don't forget to check your wp-config.php

Upvotes: 0

Yahya Hussein
Yahya Hussein

Reputation: 9121

if you have moved your wordpress website to a new domain what you have to do is to run these queries one by one in your database

update `wp_posts` set post_content = replace(post_content,'http://oldurl','http://newurl');
update `wp_posts` set guid = replace(guid ,'http://oldurl','http://newurl')
update `wp_options` set option_value = replace(option_value,'http://oldurl','http://newurl')

Upvotes: 0

Cristiano Baptista
Cristiano Baptista

Reputation: 176

You should also update the home option on the wp_options table to match the new domain, not only siteurl

Upvotes: 1

Related Questions