//查找匹配的URL private string get_url_rewrite(string channel_id, int id) { Hoto.BLL.url_rewrite bll = new Hoto.BLL.url_rewrite(); Hoto.Model.url_rewrite model = bll.GetInfo(channel_id, "detail"); if (model != null) { return(linkurl(model.name, id)); } return(""); }
/// <summary> /// 返回URL重写统一链接地址 /// </summary> public string linkurl(string _key, params object[] _params) { Hashtable ht = new Hoto.BLL.url_rewrite().GetList(); Hoto.Model.url_rewrite model = ht[_key] as Hoto.Model.url_rewrite; if (model == null) { return(""); } try { string _result = string.Empty; string _rewriteurl = string.Format(model.path, _params); switch (config.staticstatus) { case 1: //URL重写 _result = config.webpath + _rewriteurl; break; case 2: //全静态 _rewriteurl = _rewriteurl.Substring(0, _rewriteurl.LastIndexOf(".") + 1); _result = config.webpath + HotoKeys.DIRECTORY_REWRITE_HTML + "/" + _rewriteurl + config.staticextension; break; default: //不开启 string _originalurl = model.page; if (!string.IsNullOrEmpty(model.querystring)) { _originalurl = model.page + "?" + Regex.Replace(_rewriteurl, model.pattern, model.querystring, RegexOptions.None | RegexOptions.IgnoreCase); } _result = config.webpath + _originalurl; break; } return(_result); } catch { return(""); } }