From 54c393cd99be85301a3505516048e7ad9b67bf09 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Wed, 23 Aug 2017 17:25:20 +0200 Subject: [PATCH] Add more generic cases --- scripts/change_url | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 2f65629..d3d583e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -57,7 +57,11 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then - ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path" + # Replace locations starting with old_path + # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) + sudo sed --in-place "s@location\( \(=\|~\|~\*\|\^~\)\)\? $old_path@location\1 $new_path@" "$nginx_conf_path" + # Replace path in "return" directives + sudo sed --in-place "s@return \([[:digit:]]\{3\}\) $old_path@return \1 $new_path@" "$nginx_conf_path" fi # Change the domain for nginx