Changing the URL in WordPress
Changing the URL of a WordPress website can be a daunting task, but it is a necessary step when migrating your website to a new domain or subdomain. In this blog post, we will go through the steps on how to change the URL in WordPress from an old URL to a new URL, both via the WordPress Dashboard and via MySQL.
Changing the URL via the WordPress Dashboard :
The first method we will be discussing is changing the URL via the WordPress Dashboard. This method is recommended for beginners as it does not require any coding or SQL knowledge.
- Log in to the WordPress Dashboard of your website.
- Go to the Settings > General.
- Under the “WordPress Address (URL)” and “Site Address (URL)” sections, change the URLs to the new URL.
- Click on the “Save Changes” button.
Changing the URL via MySQL :
The second method is changing the URL via MySQL. This method is recommended for advanced users who are familiar with SQL and have access to the database of their website.
- Make a backup of your database.
- Access the MySQL command line or use a tool like phpMyAdmin to access your WordPress database.
- Run the following query, replacing ‘old_url’ with your old URL and ‘new_url’ with your new URL:
UPDATE wp_options SET option_value = replace(option_value, 'old_url', 'new_url') WHERE option_name = 'home' OR option_name = 'siteurl';
- Run the following query, to update the URLs in the post content:
UPDATE wp_posts SET post_content = replace(post_content, 'old_url', 'new_url');
- Run the following query, to update the URLs in the post GUID:
UPDATE wp_posts SET guid = replace(guid, 'old_url','new_url');
- Run the following query, to update the URLs in the post meta:
UPDATE wp_postmeta SET meta_value = replace(meta_value,'old_url','new_url');
- Clear the cache of your website.
- Check your website to see if everything is working fine.
Conclusion :
Changing the URL of a WordPress website can be a daunting task, but it is a necessary step when migrating your website to a new domain or subdomain. In this blog post, we have covered two methods on how to change the URL in WordPress, both via the WordPress Dashboard and via MySQL.
It is important to note that both of these methods should be tested in a development environment before applying them to a live website. In addition, you should also update your permalinks, update internal links and external links to your website, and also update your Google Analytics, Google Search Console, and other webmaster tools to ensure that your website is properly indexed and tracked in search engines.
SEO Friendly Tips :
- Use the keyword in the title of your blog post.
- Use the keyword in the H1 heading of your blog post.
- Use the keyword in the meta description of your blog post.
- Use the keyword throughout the blog post in a natural way.
- Use internal and external linking throughout the blog post.
- Optimize images.