Nov 6

二级域名自己定义转向! 不指定

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string siteUrl = GetHostName();
        siteUrl = siteUrl.ToLower();
        siteUrl = siteUrl.Replace("http://","");
        string goToUrl = "http://www.shanglin.net";
        this.Label1.Text = siteUrl;

        if (siteUrl.IndexOf("shanglin.net") > 0)
        {
            string userDomain = siteUrl.Replace(".shanglin.net", "");
            string sql = "select uid from supe_userspaces where  domain='" + userDomain + "' ";
            MySqlDataReader rs = DataAccess.mySqlDataReader(sql);
            if (rs.Read())
            {
                goToUrl = "http://club.shanglin.net/?uid-" + rs.GetInt32(0);
            }
            rs.Close();          
        }
        else if (siteUrl.IndexOf("actimind.cn") > 0)
        {
            goToUrl = "http://www.actimind.cn";
        }
        Response.Redirect(goToUrl);
    }
    
    public static string GetHostName()
     {
      return GetHostName(HttpContext.Current.Request.Url+"", true);
     }
    
     public static string GetHostName(bool hasHttp)
     {
      return GetHostName(HttpContext.Current.Request.Url+"", hasHttp);
     }
    
     public static string GetHostName(string url, bool hasHttp)
     {
      string[] UrlSet = url.Split('/');
      if(hasHttp)
      {
       return UrlSet[0]+"//"+UrlSet[2];
      }
      else
      {
       return UrlSet[2];
      }
     }
}
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]