How to Change the URL of a WordPress Website
There are many reasons why you might want to change your WordPress URL. It may be because you are moving from HTTP to HTTPS, changing to a brand new domain name, migrating from your local server to a live one or transferring to a subdomain among other reasons. The best news is that it is not hard to change your URL and there are several methods you can use for that.
WordPress Address versus Site Address
When you want to change WordPress site URL you will have to update two settings; WordPress Address and site address. WordPress Address is the address in which your WordPress files are stored. This includes the media files, themes, plugins, admin pages and so on. Site Address is the public facing part of your WordPress website. This is what visitors enter into their browser to get to your site.
In most cases, the WordPress Address and the Site address URLs are the same. However, this may different for the big companies that host their WordPress site on different servers because their site has many applications. With that out of the way, let’s take a look at the methods you can use to change your website’s URL.
From the Admin Area
This is the easiest method. You just login to the WordPress admin area and go to Settings>>General page. You will be able to change the URLs under ‘WordPress Address’ and the ‘Site Address’ options. Save the changes and you are done.
Using functions .php file
If you cannot access the admin area then this is the option for you. You have to start by connecting your site to an FTP client then go to /wp-content/themes/your-theme-folder/. Locate the ‘functions.php file’ then edit it in a text editor such as TextEdit or Notepad. Add this code at the very bottom:
update_option( ‘siteurl’, ‘https://example.com’ );
update_option( ‘home’, ‘https://example.com’ );
Replace https://example.com with your own site URL. Save the changes and upload the file to your site using the FTP client. The best thing about using functions.php file is that you get to update the URLs in your database. WordPress will update the site URL each time the functions file is loaded. Remove the two lines of code you pasted earlier when everything goes back to normal.
Using wp-config.php file
If you are not sure which WordPress theme you use then this is the method you should use. The method adds the site URLs to the WordPress configuration file known as wp-config.php. The file is in the root folder and contains crucial WordPress settings. Again you need to connect your website using FTP client then edit the wp-conig file. Add the below code above the lines ‘That’s all, stop editing! Happy publishing’.
define( ‘WP_HOME’, ‘https://example.com’ );
define( ‘WP_SITEURL’, ‘https://example.com’ );
Replace the https://example.com with your domain name. save the changes and upload the file to the server. You are done.