Do you want to migrate your WordPress website to a new URL and are not sure about how to update the old URLs in the database? MilesWeb offers you the URL hosting with free migration feature and host it hassle Free. Also, if you don’t want to go with the tedious manual process of changing the URLs, here’s a guide for you!
We’ll get to know the easy ways to update the URL of your WordPress website.
There are times when you want to migrate your WordPress website to a new URL. You don’t just need to update the website URL. Rather you also need to update the URLs in the database that includes the different MySQL database tables.
If you have a considerably small website, it’s possible to update the URL manually. But, if you have a large website with huge data, it’s not possible to update the old URL manually. Also, changing the URLs in bulk on the website is a very time-consuming process, and while doing this, you may even miss out on updating some of them.
Finding automated solutions like doing mass searches and replace of old URL’s is essential in these scenarios. In this article, we will take a look at some of the easy ways to update the site’s URL when migrating a WordPress website.
When Should You Update WordPress Website URLs?
Here are some of the common scenarios that let you update the old URLs in the database.
- Migrating a WordPress website to a new web server
- Move from HTTP to HTTPs
- Shifting website from one domain to another domain on the same web server
- Change the directions of WordPress on the existing server
When updating the URL of the website, you need to make sure that some additional aspects also need to be taken care of with changing the URL on the settings page. If the images do not have external CDNs, the links to the old URL will be embedded in the posts.
Also, these links seem to be broken whenever anyone views the page. If you have a small website, it’s good to replace two or three URLs manually. But, if you have a large website or blog, and have many images, it’s not easy to change each one. You need to find out an automated approach to replace the URLs in the database in bulk.
Ways To Change the Old URL’s in Database
The first thing you need to do before changing the URLs is that you need to take a complete backup of your WordPress database. If there’s any mistake or anything goes wrong, you can take back the changes again.
You can do the manual backup of the database or take advantage of the free WordPress plugins. Let us now get to know the different methods for changing the WordPress site URLs.
Updating the Website URLs Manually- For small websites
If you have a small website, you can go with manually replacing URLs across the website.
At many times, you need to look out for content where you place one link to the home page and the other internal pages, and just edit them. This method is applicable when you have a one-page or small website, as this will avoid the expenses of plugin installations on your website.
Change the URL in the Database
While changing the URLs, you will face some issues frequently like:
Old URLs in the Widgets and Menus:
- The old URL exists not only in posts but also in the menus and widgets.
- Broken Images and Video Links: If you have replaced the URL of your website, sometimes it may happen that the images do not function properly. This can even lead to issues with the page display if you do not update the image URLs.
The URLs are stored in different database tables, and you can change them manually. The URLs for the custom menu are present in the meta-value field in the wp_postmeta table. And the image URLs are present in the posts_content field in the wp_posts table. For the old link manager, the image URL’s are present in the link_inage fields in the wp_links fields.
You need to first make sure what to replace. Places where you will be able to find the URL on your website.
- Inside the posts and pages: “posts_content” field in the “wp_posts” table.
- Old link manager: “link_url” and “link_image” filed which are present in the “wp_links” table
- Custom Menu URLs: “meta_value” field present in the “wp_postmeta” table
- Themes and plugins: “option_value” field in the “wp_options” table
- URLs present in the comment section: “comment_content” field in the “wp_comments” table
You can update the database in the URL by changing the above tables and fields.
Using PHPMyAdmin Script for Search and Replace in Database
With MySQL, you can execute raw queries both to find, replace and use it to update the URL database. This is one of the ideal ways to change the URLs if you have a very big website that needs several changes.
Updating Links with MySQL
You can utilize the MySQL replace command to search and replace the text which is inside the database tables.
To update the URL, you need to run the query given below over different tables and fields.
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find string’, ‘replace string’);
Then, open the PHPMyAdmin panel and go to log in.
Click on the WordPress database
To replace the URL’s across all the database tables, click on the SQL tab and type the code given below:
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL'); UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL'); UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL'); UPDATE wp_comments SET comment_content = replace(comment_content , 'Existing URL','New URL');
If you are having the images linked to your posts, then you need to also run the additional queries:
If you have images inside the posts:
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
For images linked in the old manager:
UPDATE wp_links SET link_image = replace(link_image, 'Existing URL','New URL');
If you have images linked as attachments
UPDATE wp_posts SET guid = replace(guid, 'Existing URL','New URL');
- All the queries given above run for default tables known for having the URL entries in WordPress.
- Just click on the Go button
- The existing URL would be updated to site wide to a new URL.
Updating the Old URLs in the Database using WordPress Plugins
If you are not able to update the URLs by running the MySQL queries, then you have another option of doing it with the WordPress plugins. These plugins let you update the old URL’s in the database.
Here are some of the plugins which will help you to update the old URL’s in the database:
Search and Replace Plugin
With the Search and Replace plugin gives you can interface in WP-Admin to search and replace the texts across the blog or website. You can also perform a simple search or “search and replace”. Here you can place the old URL in the search box, and then replace it with the new URL. It will ask you if you want to update both the title and content, select accordingly.
Also, you have to check the posts or the pages box, and then click on Go!
Better Search Replace Plugin
It’s one of the plugin to update the URL’s in WordPress database. It lets users to replace the URL within all or just a few database tables.
Velvet Blues Update URLs
The Velvet Blues Updates URL plugins gives you the options to change the URLs at different points like the pages, posts and so on. You have to enter the old and new URL’s of your website.
After then, you need to select where the URL of your website needs to be updated.
WP migrate is basically a WordPress migration plugin that makes the it easy to export and migrate your database. The migration takes place like: First, find the replace the data you want from the WP migrate interface
WP site owners many times need to change the URL of their WordPress website. The entire process of changing the old URLs in the database is quite lengthy and requires a lot of patience if it’s done manually.
In many scenarios, doing just a simple search and replace will work best for small websites and blogs. However, it is preferred to use the “serialize-data sensitive” search and replace tool or plugin to change the image and URL of the website. These tools would be very helpful in moving a website and replacing its URL with the other one. Hope this article has helped you! If you are still confused about changing the WordPress site URLs, you can ask for assistance from experts.