How to Change URL from Database using Command

You want to change URL from database like http://domain.com/wp-content to https://www.domain.com/wp-content. So you can easily to change URL using simple command on apache server.

How to Do

  • Open terminal or SSH and login there.
  • Go to directory using cd /var/www/html command.
  • Then use given command to change WordPress’s site url and home url.
wp option update siteurl 'https://doamin.com'
wp option update home 'https://domain.com'
Example
wp option update siteurl 'https://thekro.com'
wp option update home 'https://thekro.com'
  • Now use given command to change URL from database.
wp search-replace 'http://olddomain.com' 'https://newdomain.com'
  • When you complete these process, Then verify changes using command.
wp option get siteurl
wp option get home
  • If successfully change URL. So exit terminal using exit command.

Hope this procedure helpful for you. Thanks for visiting.

Watch Video

FAQ

Can use this code on Google cloud/digital ocean’s apache sevrer.
Yes, you can use these steps on your apache server.