When deploying a site (and database) from development to production, when going to the production the site goes back to development.
That’s because in WordPress, site URL is defined and saved in database by default.
According to the official document, there are several ways to change URL.
Method 1: update database
URL information are installed in <prefix>_options table. Locate option_names ‘siteurl’ and ‘home’ and update option_value to the new URL.
Or run this SQL after copying the database to production:
update <prefix>_options set option_value = 'http://yoursite.com' where option_name = 'site_url' or option_name = 'home'
Method 2: update config file – relocation
wp-config.php and add the following code after all the define statements:
Login to the new site after the above change.
Important: this line must be removed after login.
You will need to go to setting to update the site url in General Settings.
Method 3: update config file – add url information
wp-config.php and add the following code:
The URL information saved in the database will be ignored.
Note that the urls also can’t be changed via General Settings.
Important: update internal links
In WordPress, absolute path is used for internal links. You you need to globally update all internal links to the new URL as well.