If you want to copy your WordPress site from your development environment to the production server, if you want to change your blog name or simply there is an issue with your domain name – you may need to change the URL which is used by your blog. This is required in order for the menu to work properly, for assets to load and for your users to be able to browse your site flawlessly.
The easiest way to change URL is to use Settings
Given that you are still using the old domain name, you can simply log in to Admin panel and go to Settings -> General. You will find there two fields: WordPress Address and Site Address
You can simply put there your new URL address and save the changes. Now you are ready to switch your server to the new domain or to backup the database and restore on your new server.
What if I’m already on the new server and my admin is not loading?
If you already copied your blog to the new server or you had to change your domain name you may not be able to load admin interface. In such case, there are various methods to adjust WordPress URL – the first one you should try is to adjust wp-admin.php file. You should simply add these two lines to the configuration:
Once these lines will be added, you can simply save wp-admin.php and load your blog again – it should now work properly using new URL. Please note that in my example I used HTTPS protocol – if your site is not working with HTTPS, use HTTP instead.
Almost the same method can be used to adjust the URL in your theme functions.php file – this can be helpful if you don’t want or you can not edit your wp-config.php file. In order to do this, locate your theme directory and edit functions.php file by adding the following lines almost at the beginning of the file, just after <?php opening
Once adjusted, go to your new site URL, load the site and go to the admin login form. Just to be on the safe side, load login page or admin page few times. Remember to remove these lines from functions.php file afterward. They should not stay in there.
I have no access to the files but I can adjust database, can I fix my URL?
You can adjust your blog URL also in the database itself. Please remember to make a copy of your database before proceeding.
The place where the URL is stored is the table named wp_options – please note that the name of the table may differ if you are not using wp_ prefix for your database tables. You will have to locate the table row with the “option_name” column set to “siteurl” – this is the row in which your site URL is stored. You will have to edit “option_value” column of this row to reflect your new URL.
Once your database is adjusted, you can load your blog in the browser – you should now be able to use it normally.