captaincore/lib/remote-scripts/apply-https
2020-08-18 20:28:16 -04:00

26 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Apply SSL using domain without www
#
domain=$(wp option get home)
domain=${domain/http:\/\/www./} # removes http://www.
domain=${domain/https:\/\/www./} # removes https://www.
domain=${domain/http:\/\//} # removes https://
domain=${domain/https:\/\//} # removes http://
domain=$( echo $domain | awk '{$1=$1};1' ) # Trims whitespace
echo "Search and replace http://$domain to https://$domain"
wp search-replace http://$domain https://$domain --all-tables --skip-plugins --skip-themes --report-changed-only
echo "Search and replace http:\/\/$domain to https:\/\/$domain"
wp search-replace "http:\/\/$domain" "https:\/\/$domain" --all-tables --skip-plugins --skip-themes --report-changed-only
echo "Search and replace http://www.$domain to https://$domain"
wp search-replace http://www.$domain https://$domain --all-tables --skip-plugins --skip-themes --report-changed-only
echo "Search and replace http:\/\/www.$domain to https:\/\/$domain"
wp search-replace "http:\/\/www.$domain" "https:\/\/$domain" --all-tables --skip-plugins --skip-themes --report-changed-only
wp cache flush