From 945b9b57fcaa15ef39b75cf684e6d7e4bfadcc01 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 7 Aug 2025 17:52:00 +0800 Subject: [PATCH] Add https on wp-config.php --- scripts/wp-search-replace.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/wp-search-replace.sh b/scripts/wp-search-replace.sh index ba7e8ef..582d429 100644 --- a/scripts/wp-search-replace.sh +++ b/scripts/wp-search-replace.sh @@ -217,8 +217,13 @@ success "All search-replace tasks completed successfully." CONFIG_FILE="$WP_ROOT/wp-config.php" if [[ -f "$CONFIG_FILE" && -w "$CONFIG_FILE" ]]; then info "Updating WP_HOME and WP_SITEURL in wp-config.php …" - # Use the new URL without trailing slash + # Use the new URL without trailing slash, ensure it has https:// TARGET_URL="$NEW_NORMAL" + # Ensure URL starts with https:// + if [[ ! "$TARGET_URL" =~ ^https:// ]]; then + TARGET_URL="https://$TARGET_URL" + info "Added https:// prefix to URL: $TARGET_URL" + fi # shellcheck disable=SC2016 # we want literal single quotes inside sed replacement sed -i -E "s|define\(\s*'WP_HOME',\s*'[^']*'\s*\);|define( 'WP_HOME', '${TARGET_URL}' );|; s|define\(\s*'WP_SITEURL',\s*'[^']*'\s*\);|define( 'WP_SITEURL', '${TARGET_URL}' );|" "$CONFIG_FILE" || warning "Failed to update wp-config.php" else