How to replace links on the WordPress website in bulk?
March 25, 2016Comments (1)
Need to replace many links on your website at once? Don’t worry, this routine task can be automated. Here you will learn how to do it quickly and easily.
Webmasters don’t like to concern themselves with routine work, in particular the one giving no immediate satisfaction. No doubt, bulk change of links on the website is one of them: though it is done not so often, only some of them are satisfied with the prospect of killing their time on the change of hundreds of URLs by hand.
However, if you really have to do it (when moving to a new domain, or, for example, you want to replace the existing links t Travelpayouts URLs), don’t worry. Feel free to turn this task over to a soulless machine. How? Read our selection of TOP 3 most convenient ways to do it!!
Table of Contents
#1: MySQL query
This is the easiest and universal recipe for a quick change of all links on your website involving a direct work with MySQL database (unless you use this system).
Your actions are as follows. First, sign in to phpmyadmin, find your database there containing “wp_posts” table (if you are using WordPress) with the “X” field storing the URLs. Then, you should open the SQL tab and execute the following query:
UPDATE wp_posts SET Х= REPLACE (Х, “an old link”, “a new link”)
Now you have just to click “Go” (or a corresponding icon, if your interface differs). It’s a done deal!
#2: PHP script upload to the website
Bulk link change is a well-known issue. No wonder that ready-made solutions have been already provided: Search and Replace script by the Interconnect Company. Though it has been initially created for WordPress, it is applicable to other popular CMS (such as Drupal or Joomla).
ИIts use is simple as falling off a log: download zip file using the link above, extract the search-replace-db-master folder (for ver. 3.1.0), rename it if needed and upload via ftp to a public directory of your hosting (but not in the website root, remember it!).
Back up your database (never, never forget to make a backup!) and open the uploaded folder on your server via your browser’s address bar. The script launches automatically, so you will have only to choose the database and links you are going to replace.
#3: Better Search Replace plugin for WordPress
Hate to upload other people’s scripts to your website? We know it, so we’ve got an alternative for the owners of WordPress websites. Perhaps, this CMS has the most convenient plugin for bulk link change – Better Search Replace. It is easily integrated, compatible with any hosting (according to its developers), and seems perfect for work with WordPress Multisite.
Everything is quite simple. For example, when moving your site you’ll have to do the following: firstly, it is necessary to integrate the plugin and make a backup of the database (obligatory!), as well as to install the database and engine on a new hosting. Then you should specify a new URL in wp-config.php (learn more about it here), log in to the admin panel of the new website and launch Better Search Replace to replace old URLs with new ones.
And it’s almost fixed – now you have just to remove the changed parameter site_url from wp-config.php and generate a new .htaccess file (via Settings-Permalinks in WordPress admin panel) if needed. And don’t forget to back up your database each time you work with it, unless possible errors caused by plugin customization can kill your website!
All of them will be useful not only when moving your site and replacing one URL with another one, but they will also help you quickly and easily turn all the words “flights” in your posts into links marked as Jetradar, and “hotels” – as Hotellook.
However, if you still doubt about your abilities and skills, you’d better find a specialist. This will help you avoid possible problems with your website, thus preserving your time, money and efforts.
P.S. We’ve got great news for those using our plugin for WordPress: we are planning to enrich its basic functionality with one more function – bulk link change. The work … is in full swing!