How To Change the WordPress site URLs? – 4 Easy to Follow Methods

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?

WordPress Address URL:
WordPress Address URL represents the location of your WordPress core files. Most of the site’s WordPress core files are located in the default folder called root. If you installed WordPress on a subdirectory, then the typical WordPress Address URL looks like this.
https://yoursiteurl.com/wordpress/
Site Address URL:
The site address represents the location of your webpage. For example, People visit your blog or website using URL or Web address.
E.g., https://wpblogx.com

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.

Most of the time, both WordPress and Site URLs are the same. Finally, don’t forget to click the ‘save changes‘ button at the end of the settings page. After this update goes to your domain name to check your site works properly.
wordpress and site address url
Note: Think before update these fields because If you made any mistake, your site wouldn’t work. In case you already made a mistake, you can still make your site work by using the wp-config.php method. In method 3, I explained full details about wp-config follow them.

Method 2: Change WordPress URLs using wp-config.php File

This method is recommended only if you can’t locate your currently installed theme and functions.php file.
The wp-config.php file is located in the root directory; you can log in to root using the cPanel or FTP method. Here we use cPanel to edit the WP Config file, and its link looks like this:
https://yoursiteurl.com/cpanel
After login to your website cPanel and navigate to File Manager > (click) public_html> (edit) wp-config.php file.
edit wp-config.php file using the internal file editor

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.

Eg: /wp-content/themes/your-current-theme-folder

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.

edit functions.php file using the internal file editor

 

 

 

 

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.

go to cpanel and click phpmyadmin

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.

find your database name in phpmyadmin

Step 3: Click the database name you want to edit, and after clicking, you will see the list of database tables. From this list, you need to click the wp_options database table.
database wp_options
Step 4: Now, you can see the URL and home URL row and update the option_value column with what you want to add. You can edit the rows by using the pencil icon on the left side.
edit option_value
Step 5: In my case, I will remove the WordPress subdirectory in both the site URL and Home URL. Based on your need you can do anyone or both.
option_name url updated
Step 6: Now, both WordPress URLs are updated.
new option values updated
After updating the database please verify if they work properly or not.

Conclusion

We hope you got an idea of how To Change the WordPress and Site Address URLs, from within the dashboard by using URL settings or by using the wp-config file or by using the database.
If you need to know how to move the WordPress Subdirectory files to the root folder follow this article.
If you have any questions or queries, please comment and let me know if this helped you. You can also find us on Twitter and Facebook.

Leave a Comment

%d