Add https on wp-config.php
parent
f671993002
commit
945b9b57fc
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue