People might want to change WordPress URLs for many different reasons. Here are the most important reasons for changing WP URLs, moving WordPress to subdirectory or subdomain, migrating to a new domain, Adding or removing www, Switch HTTP to HTTPS, and moving WordPress localhost to a production server.
In this post, I will teach you how to change WordPress Home and Site URL in a step by step manner. Let us see about four different ways to change WordPress URLs.
If you need any help regarding our post, contact the WPBlogX team will help with a small fee.
What is the difference between WordPress and Site Address URLs?
Table of Contents
- 1 What is the difference between WordPress and Site Address URLs?
- 2 Method 1: Change WordPress URLs through the WordPress Dashboard
- 3 Method 2: Change WordPress URLs using wp-config.php File
- 4 Method 3: Change WordPress URLs via Functions.php File
- 5 Method 4: Change WordPress URLs in MySQL Database using phpMyAdmin
- 6 Conclusion
- 7 Share this post:
Method 1: Change WordPress URLs through the WordPress Dashboard
You can change WordPress URLs from your WordPress Admin dashboard easily which is a common method. First, you need to login to your WP admin page.
After login, Go to Settings > General page, and then you need to update fields based on your requirements, such as WordPress Address(URL) and Site Address URL.
Method 2: Change WordPress URLs using wp-config.php File
You need to paste this code before the line inside the wp-config file ‘That’s all, stop editing! Happy Publishing’.
Here is the code:
define( ‘WP_HOME’, ‘https://yoursiteurl.com’ );
define( ‘WP_SITEURL’, ‘https://yoursiteurl.com’);
In the above code, replace https://yoursiteurl.com with your domain name. Don’t forget to click the ‘Save Changes’ button.
Finally, go to your domain URL to see whether the site works properly or not.
Note: If you apply this method, the WordPress Admin page settings will be hardcoded, and this will override the WordPress URL. Due to this, in the WP admin settings page, the URL fields will be grayed out. If you want to undo the changes, you need to remove these codes from your wp-config.php file.
Method 3: Change WordPress URLs via Functions.php File
If you can’t log in to your WP admin area, then follow this method.
You can modify WordPress URLs by using the functions.php file, which can be found in the currently active theme; you need to login to cPanel and open your File Manager > Public_html folder follows this path.
Note: You can also login to your public_html by using software called FileZilla FTP Client. Both cPanel and FTP methods are recommended; you can choose whichever suits you the best.
As you can see in the above screenshot and edit the file using the internal server code editor. If you are using an FTP client, you can use NotePad like text editor for code editing purposes.
After open, the functions.php file adds the following code at the end.
update_option( ‘siteurl’, ‘https://yoursiteurl.com’ );
update_option( ‘home’, ‘https://yoursiteurl.com’ );
For example, in my case, I will replace it with my domain.
https://yoursiteurl.com with https://wpblogx.com.
After adding URLs, don’t forget to click the ‘save changes’ button on the page’s top right corner.
Now check your site after this update whether your site works normally or not.
This method’s main benefit is that every time functions load, it will update the site URL in the database option so that you don’t need to worry about the change happened or not.
Method 4: Change WordPress URLs in MySQL Database using phpMyAdmin
You can update WordPress URLs on MySQL Database by using phpMyAdmin.
Before update your database, you need to take a database or full site backup! Because if something goes wrong, you can revoke the previous state by using your backup files.
In WPBlogX, we are using WPVivid Pro for taking database and WP file backups.
Step 1: You need login to cPanel or hosting control panel by typing a URL like this on your browser address bar https://www.wpblogx.com/removing-wordpress-from-url/
After login to your cPanel, you need to search PHP on the search bar to find and then click the phpMyAdmin icon or link.
Step 2: Now phpMyAdmin is opened, you can find the list of database names on the lift side of the phpMyAdmin page.
If you don’t know your WordPress website database name, refer here to finding your WP database name.
Prabhu Ganesan provides his web development and WordPress services independently. He is the founder of WPBlogX. He is very much involved in WordPress as it becomes second nature for him. You can get in touch with him by visiting his website – WPBlogX.com and you can also find him on Twitter @gprabhucbe.