Switch the WordPress database from http to https
switch wordpress to https | fix mixed content wordpress | replace http links in wordpress | still http after ssl certificate | wp-cli | search-replace | https | seoWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
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/httpdocsFirst 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