support multi level gatewayPath
diff --git a/api-gateway-config/scripts/lua/lib/filemgmt.lua b/api-gateway-config/scripts/lua/lib/filemgmt.lua
index 343eaea..36d6192 100644
--- a/api-gateway-config/scripts/lua/lib/filemgmt.lua
+++ b/api-gateway-config/scripts/lua/lib/filemgmt.lua
@@ -51,11 +51,10 @@
     os.execute(utils.concatStrings({"mkdir -p ", baseConfDir, namespace}))
     local file, err = io.open(utils.concatStrings({baseConfDir, namespace, "/", gatewayPath, ".conf"}), "w")
     if not file then
-        ngx.status(500)
         ngx.say(utils.concatStrings({"Error adding to endpoint conf file: ", err}))
-        ngx.exit(ngx.status)
+        ngx.exit(500)
     end
-    local location = utils.concatStrings({"location /api/", namespace, "/", gatewayPath, " {\n",
+    local location = utils.concatStrings({"location /api/", namespace, "/", ngx.unescape_uri(gatewayPath), " {\n",
                                           prefix,
                                           outgoingRoute,
                                           proxyPass,
diff --git a/api-gateway-config/scripts/lua/lib/redis.lua b/api-gateway-config/scripts/lua/lib/redis.lua
index d328dd0..52abe21 100644
--- a/api-gateway-config/scripts/lua/lib/redis.lua
+++ b/api-gateway-config/scripts/lua/lib/redis.lua
@@ -245,7 +245,7 @@
 
             local routeObj = _M.getRoute(red, redisKey, "route", ngx)            
             _M.createRoute(red, redisKey, "route", routeObj, ngx)
-            filemgmt.createRouteConf(BASE_CONF_DIR, namespace, gatewayPath, routeObj)
+            filemgmt.createRouteConf(BASE_CONF_DIR, namespace, ngx.escape_uri(gatewayPath), routeObj)
             ngx.say(utils.concatStrings({redisKey, " updated"}))
             ngx.log(ngx.INFO, utils.concatStrings({redisKey, " updated"}))
             ngx.flush(true)
diff --git a/api-gateway-config/scripts/lua/management.lua b/api-gateway-config/scripts/lua/management.lua
index 53ecc1d..a0842e8 100644
--- a/api-gateway-config/scripts/lua/management.lua
+++ b/api-gateway-config/scripts/lua/management.lua
@@ -218,7 +218,7 @@
         ngx.exit(ngx.status)
     end
 
-    local redisKey = utils.concatStrings({prefix, ":", namespace, ":", gatewayPath})
+    local redisKey = utils.concatStrings({prefix, ":", namespace, ":", ngx.unescape_uri(gatewayPath)})
     return redisKey, namespace, gatewayPath
 end