↑ ↓ select, Enter open, Esc close

Switch the WordPress database from http to https

Adjust the values, the command updates live
user@server
wp db export /var/www/vhosts/example.com/before-https.sql --path=/var/www/vhosts/example.com/httpdocs && wp search-replace 'http://example.com' 'https://example.com' --skip-columns=guid --path=/var/www/vhosts/example.com/httpdocs

First exports the database as a backup, then replaces http://example.com with https://example.com in all WordPress tables, including serialized data. This fixes mixed content warnings and stops internal links from going through a redirect, which also matters for SEO. The guid column is deliberately left unchanged.

Note: Test with --dry-run first. Also set up a 301 redirect from http to https at the web server level, and replace subdomains such as www. separately if needed.

Also searched as

  • switch wordpress to https
  • fix mixed content wordpress
  • replace http links in wordpress
  • still http after ssl certificate

Related one-liners

All in WP-CLI

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.