Wordpress WP_SITE_URL and WP_HOME values?

2019-09-09 15:13发布

I have a single WordPress installation and my website is at "abc.com/site". Everything works great.

I want to move my site to "abc.com". The instructions I got from my hosting company are described at the link "codex.wordpress.org/Changing_The_Site_URL"

Do I simply need to edit my wp-config file to the following ?

define('WP_HOME','http://www.abc.com');
define('WP_SITEURL','http://www.abc.com/site');

I have never done this before and not sure about the correct values for WP_HOME and WP_SITEURL. Can you please help me. I don't want to break anything.

Thank you

标签: wordpress url
2条回答
Luminary・发光体
2楼-- · 2019-09-09 15:56

you can get by following

define('WP_HOME','http://www.abc.com');
define('WP_SITEURL','http://www.abc.com/');

WP_HOME and WP_SITEURL must be same, you can also update your siteurl, home in your wp_options table

查看更多
男人必须洒脱
3楼-- · 2019-09-09 16:00

This answer merely extends Jothi Kannan's answer

If you want to move a WordPress site to a new domain you need to also consider Filepath names stored in your database may have absolute URLs linking to the previous domain name.

If you have access to run SQL (maybe through PHPMyAdmin, SQL tab) then you might want to consider running the following queries on your new domain to ensure all domains have changed.

Change the values in wp_options

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

Match and replace old site URL in wp_posts guid

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');

Match and replace old site URL in wp_posts post_content

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

An alternative to this is using a plugin called Duplicator which is brilliant - but requires a certain level of system resources to function properly in my experience. Duplicator will take a dump of your website where you can deploy it to a different environment using an installer.php file.

It will import your database and change all the URLs for you as long as you specify the correct database credentials during installation.

查看更多
登录 后发表回答