change url of wordpress site

change-wordpress-url

Here I have tried to give as many examples that I could think of based on my own experience, and what I have found useful When it comes to making changes to your URL.

There are many reasons why you may want to change a websites URL; from setting up permalinks at the start to changing URLs either through changing websites completely, moving to a new director or moving to a more secured domain.

Reasons Why You Might Need to Change Your WordPress Site URL

This doesn’t happen often but there are some reasons why you may need to change the URL of your website:

Domain Name Change Rebranding your business or changing your website’s focus might require a new domain name. This involves updating the WordPress site URL to reflect the new domain.

Moving to a New Directory Sometimes, you might need to move your WordPress site to a new directory on your server. For instance, moving from a subdirectory to the root directory.

Switching from HTTP to HTTPS Enhancing your site’s security by switching from HTTP to HTTPS requires changing your site URL to include the new protocol.

Also, depending on who your hosting provider is, but I generally contact my hosting tech support team to add on an SSL, often there is a charge for this but is something that is strongly recommended.

Tips: If your setting up a new WordPress website start by setting up your permalinks. This way your URLs will be ready to go as soon as you start adding posts or pages:



Also for those interested in ever needing to change the end of their URL to htm or HTML, here is another way to set this up via permanlinks:

Preparation Steps when changing url

when wanting to change the URL of a website completely our internally here are some useful actions to consider:

Backup Your WordPress Site Before making any changes, back up your entire WordPress site. This includes your database, themes, plugins, and media files. Use a reliable backup plugin or your hosting provider’s backup services.

Ensure You Have Access to Your Hosting Account and Database Verify you have the necessary access credentials for your hosting account and database. This is crucial for making changes and troubleshooting any issues that may arise.

Changing the URL in WordPress Settings

Accessing the WordPress Dashboard Log in to your WordPress dashboard using your admin credentials.

Navigating to Settings > General Once in the dashboard, go to the left-hand menu and navigate to Settings. Click on General to access the site URL settings.

Updating the WordPress Address (URL) and Site Address (URL) In the General Settings, you’ll see fields for WordPress Address (URL) and Site Address (URL). Update both fields with the new URL you want to use.

Saving Changes Scroll down and click the Save Changes button to apply the new URL settings. This will update the site URL in your WordPress settings.

Updating the URL in the wp-config.php File

Locating the wp-config.php File in Your WordPress Root Directory

Connect to your site via FTP or use your hosting control panel’s file manager. Navigate to the root directory of your WordPress installation. Locate the wp-config.php file.

Editing the File to Define the New Site and Home URLs

Open the wp-config.php file in a text editor. Scroll down to the section where you can add custom configurations.

Adding the Necessary Lines of Code

Add the following lines of code to define your new site and home URLs:

define(‘WP_HOME’,’http://newsiteurl.com’);
define(‘WP_SITEURL’,’http://newsiteurl.com’);

Replace http://newsiteurl.com with your new site URL.

Saving Changes

Save the changes to the wp-config.php file. Upload the file back to the root directory if you used an FTP client.

Changing the URL in the Database

Accessing the Database via phpMyAdmin

Log in to your hosting control panel. Open phpMyAdmin.

Finding the wp_options Table

In phpMyAdmin, select your WordPress database. Locate and click on the wp_options table in the left sidebar.

Updating the ‘siteurl’ and ‘home’ Fields

In the wp_options table, find the rows labeled ‘siteurl’ and ‘home’. Click the Edit button next to each of these rows. Replace the old URL with the new URL in both fields. Click Save to apply the changes.

Running a Search-and-Replace Query to Update Old URLs Throughout the Database

Go to the SQL tab in phpMyAdmin. Run the following query to update all instances of the old URL:

UPDATE wp_posts SET guid = replace(guid, ‘http://oldsiteurl.com’,’http://newsiteurl.com’);
UPDATE wp_posts SET post_content = replace(post_content, ‘http://oldsiteurl.com’, ‘http://newsiteurl.com’);
UPDATE wp_postmeta SET meta_value = replace(meta_value,’http://oldsiteurl.com’,’http://newsiteurl.com’);

 

Updating URL in .htaccess File

Accessing the .htaccess File in Your WordPress Root Directory

Connect to your site via FTP or use your hosting control panel’s file manager. Navigate to the root directory of your WordPress installation. Locate the .htaccess file (it might be hidden; ensure you have the option to show hidden files enabled).

Updating Any Hard-Coded URLs

Open the .htaccess file in a text editor. Look for any hard-coded URLs in the file. Update these URLs to reflect your new site URL.

Saving Changes

Save the changes to the .htaccess file. Upload the updated file back to the root directory if you used an FTP client.

Using a Plugin to Update URLs

Overview of Popular Plugins

Better Search Replace Better Search Replace is a powerful plugin for running search-and-replace operations in your WordPress database. It’s user-friendly and can handle large databases efficiently.

Velvet Blues Update URLs Velvet Blues Update URLs is another reliable plugin. It’s designed specifically to update URLs across your WordPress site. It’s simple to use and can quickly update URLs in posts, pages, and other content.

Installing and Activating the Chosen Plugin

Go to Plugins > Add New in your WordPress dashboard. Search for the chosen plugin (Better Search Replace or Velvet Blues Update URLs). Click Install Now, then Activate the plugin.

Running the Plugin to Update URLs Across the Site

For Better Search Replace:

  • Go to Tools > Better Search Replace.
  • Enter the old URL in the “Search for” field and the new URL in the “Replace with” field.
  • Select the tables you want to update (typically all tables).
  • Run a dry run first to see how many changes will be made.
  • If everything looks good, uncheck the “Dry Run” box and run the search-and-replace operation.

For Velvet Blues Update URLs:

  • Go to Tools > Update URLs.
  • Enter the old URL and the new URL.
  • Select the content you want to update (URLs in page content, excerpts, attachments, etc.).
  • Click Update URLs NOW to start the process.

By following these steps, which ever applies to your personal circumstance you can change your old URL to the new URL across your WordPress site.

 
 

Similar Posts