Skip to content

PHP Articles

php | frameworks | cms | and all web things.

Menu
  • Home
  • Laravel
  • WordPress
  • Server
  • Database
  • Google
Menu
wpf

Replace Old To New Url In The WordPress Database

Posted on May 3, 2019February 4, 2021 by admin

If you are new in WordPress development and working on a client project then one thing you have to take note is that whenever you deploy your WordPress project to client-server you have to replace your site URL from local to live and the same thing will apply, If you migrate from one to another domain. If you forgot to change URL then it will redirect to the old URL and that needs to take care of it.

Another way you can avoid this problem by creating a virtual host in your local server with a live domain.

replace old to new url in the wordpress database

So how to replace old to new URL in the WordPress database? Well, it’s very easy. You just have to replace your old URL with the new URL so follow the below steps.

Step 1:

If you have already uploaded the database to the server, then go to your phpMyAdmin and open your database.

Step 2:

Copy the below code and replace your old URL with http://www.oldurl.in and do the same for the new URL.

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl.in', 'https://www.mananpatel.in') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl.in','https://www.mananpatel.in');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl.in', 'https://www.mananpatel.in');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl.in','https://www.mananpatel.in');

After replacing your old & new URL, go to the SQL section in your phpMyAdmin and past your SQL queries and hit the Go button.

After hitting the Go button, SQL queries will replace all instances of old URLs to new URLs. For example, If your current WordPress address is http://www.oldurl.in, it will be changed to https://www.mananpatel.in.

IMPORTANT! Sometimes table prefix can be different than wp_. If you get error messages saying that tables wp_options, wp_posts, wp_posts and wp_postmeta cannot be found, check table prefix and update SQL query code. You can see table prefix on the left side of phpMyAdmin, under your WordPress database:

Step 3:

If the query was executed successfully, then you will see a green success message with the number of records is affected.

Keep visiting for new stuff and give your feedback.

Happy Coding 😉

Share this:

  • Twitter
  • Facebook

Top Posts

  • Laravel Swagger Authenticate Users Via Bearer Token
  • How To Use wp_mail With WordPress
  • How To Use Darkaonline/l5-Swagger In Laravel
  • Replace Old To New Url In The WordPress Database
  • How To Change Pre-Installed PHP Version To MAMP In Mac/osx
  • Laravel Api Integration & Configuration
  • WordPress Custom Post Type Pagination

Recent Posts

  • Custom Gutenberg Block In WordPress
  • Laravel Swagger Authenticate Users Via Bearer Token
  • How To Use Darkaonline/l5-Swagger In Laravel
  • How To Fix You Already Have An Adsense Account
  • Laravel Passport Create Api For Your Application
  • Laravel Api Integration & Configuration

Archives

  • February 2021
  • July 2020
  • March 2020
  • February 2020
  • May 2019
  • January 2019
  • April 2018
  • March 2018
  • January 2018
  • December 2017

Categories

  • Ajax
  • Database
  • Google
  • Laravel
  • Server
  • WordPress
© 2022 PHP Articles | Powered by Minimalist Blog WordPress Theme