diff --git a/class/core/site_api.py b/class/core/site_api.py index 404848e25..fb9c623c1 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -1181,6 +1181,7 @@ class site_api: data_path = self.getRedirectDataPath(_siteName) data_content = mw.readFile(data_path) if data_content == False: + mw.execShell("mkdir {}/{}".format(self.redirectPath, _siteName)) return mw.returnJson(True, "", {"result": [], "count": 0}) # get # conf_path = "{}/{}/*.conf".format(self.redirectPath, siteName) @@ -1211,13 +1212,11 @@ class site_api: data_path = self.getRedirectDataPath(_siteName) data_content = mw.readFile(data_path) if os.path.exists(data_path) else "" - data = json.loads(data_content) if data_content != "" else {} + data = json.loads(data_content) if data_content != "" else [] _rTypeCode = 0 if _rType == "301" else 1 _typeCode = 0 if _type == "path" else 1 - _keepPath = 1 if _keepPath == "true" else 0 - redirect_type = "permanent" if _rType == 0 else "temporary" pathQuery = "" if _keepPath == 1: # path @@ -1231,11 +1230,14 @@ class site_api: file_content = "" # path if _typeCode == 0: - file_content = """if ($host ~ '^{}'){ - return {} {}{}; - }""".format(_from, _rType ,_to, pathQuery) - else: + redirect_type = "permanent" if _rTypeCode == 0 else "temporary" file_content = "rewrite ^{} {}{} {};".format(_from, _to, pathQuery, redirect_type) + else: + redirect_type = "301" if _rTypeCode == 0 else "302" + _if = "if ($host ~ '^{}')".format(_from) + _return = "return {} {}{}; ".format(redirect_type, _to, pathQuery) + file_content = _if + "{\r\n " + _return + "\r\n}" + _hash = mw.md5("{}+{}".format(file_content, time.time())) diff --git a/route/static/app/site.js b/route/static/app/site.js index cf119feb3..1952077c3 100755 --- a/route/static/app/site.js +++ b/route/static/app/site.js @@ -1427,16 +1427,14 @@ function to301(siteName, type, obj){ // 设置 更新展示 if(type == 1 || type == 3){ obj = { - redirectname: (new Date()).valueOf(), - tourl: 'http://', - redirectdomain: [], - redirectpath: '', - redirecttype: '', + to: 'http://', + from: '', + r_type: '', type: 1, - domainorpath: 'domain', - holdpath: 1 + type: 'domain', + keep_path: 1 } - layer.open({ + var redirect_form = layer.open({ type: 1, skin: 'demo-class', area: '650px', @@ -1448,26 +1446,22 @@ function to301(siteName, type, obj){ "
" + - " " + "