WordPress Help

Change the URL of my WordPress site in the wp-config.php file

If you're moving your website to a new server, this method can help you preview the site on a temporary domain without the need to make changes to the database. It will prevent the browser from redirecting to the old server. If your hosting plan doesn't come with a temporary domain, it can be any domain you don't use or a subdomain of a live domain.

Note: If your site is using one of the Managed WordPress hosting plans, you do not need to change URLs in the wp-config.php file to preview the site on a temporary domain.
  1. Connect to your hosting with FTP or File Manager.
  2. In the folder with your WordPress installation, find the wp-config.php file.
  3. Open the wp-config.php file and find the following line:
    /* That's all, stop editing! Happy publishing. */
  4. Just above this line, add the following code:
    define('WP_HOME','http://yourdomain.com'); define('WP_SITEURL','http://yourdomain.com'); 
  5. Replace http://yourdomain.com with your temporary domain.
  6. Save the file.
  7. (Optional) If you're using FileZilla, accept the overwrite warning in FileZilla to replace the file.

You can now visit your temporary domain in a browser and preview the website.

Required: After you have finished previewing the site, ensure that you remove the previously added code and save the file.

More info

Share this article