Win2003操作系统,IIS6,已经设置了泛解析,ISAPI Rewrite组件都有了,程序用asp.net2.0开发.如何做真正的二级域名?不要用框架,也不要用转发.
比如顶级域名是www.abc.com,一个二级域名love.abc.com可以解释到www.abc.com/love/,但浏览器的地址栏不可以转发或转向,就必须是love.abc.com.请高手帮忙.谢谢.

解决方案 »

  1.   

    楼上的兄弟,我用了URL重写.重写规则是:
    #RewriteCond Host: (?!\.|www|ww)(.*).uuu1234.com
    #RewriteRule (.*) http\://www.uuu1234.com/index\.aspx\?cityid=$1 [I,R]
    输入aaa.uuu1234.com之后,他跳到了http://www.uuu1234.com/index.aspx?cityid=aaa
    也就是浏览器的地址栏发生了变化.该如何才能让地址栏的地址不变化呢?
      

  2.   

    试一下~
    RewriteRule (.*) /index\.aspx\?cityid=$1 [I,R]
      

  3.   

    大家应该知道,微软的URLRewrite能够对URL进行重写,但是也只能对域名之后的部分进行重写,而不能对域名进行重写,如:可将 http://http://www.abc.com//1234/  重写为 http://www.abc.com/show.aspx?id=1234  但不能将 
    http://1234.abc.com/  重写为  http://www.abc.com/show.aspx?id=1234。 要实现这个功能,前提条件就是  http://www.abc.com/ 是泛解析的,再就是要修改一下URLRewriter了。 
    总共要修改2个文件 1.BaseModuleRewriter.cs protected virtual void BaseModuleRewriter_AuthorizeRequest(object sender, EventArgs e) 
            { 
                HttpApplication app = (HttpApplication) sender; 
                Rewrite(app.Request.Path, app); 
            } 
    改为 protected virtual void BaseModuleRewriter_AuthorizeRequest(object sender, EventArgs e) 
            { 
                HttpApplication app = (HttpApplication) sender; 
                Rewrite(app.Request.Url.AbsoluteUri, app); 
            } 就是将  app.Request.Path 替换成了  app.Request.Url.AbsoluteUri 2.ModuleRewriter.cs for(int i = 0; i < rules.Count; i++) 
                { 
                    // get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory) 
                    string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].LookFor) + "$"; 
     
                    // Create a regex (note that IgnoreCase is set) 
                    Regex re = new Regex(lookFor, RegexOptions.IgnoreCase); 
     
                    // See if a match is found 
                    if (re.IsMatch(requestedPath)) 
                    { 
                        // match found - do any replacement needed 
                        string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].SendTo)); 
     
                        // log rewriting information to the Trace object 
                        app.Context.Trace.Write("ModuleRewriter", "Rewriting URL to " + sendToUrl); 
     
                        // Rewrite the URL 
                        RewriterUtils.RewriteUrl(app.Context, sendToUrl); 
                        break;        // exit the for loop 
                    } 
                } 
    改为 for(int i = 0; i < rules.Count; i++) 
                { 
                    // get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory) 
                    string lookFor = "^" + rules[i].LookFor + "$"; 
     
                    // Create a regex (note that IgnoreCase is set) 
                    Regex re = new Regex(lookFor, RegexOptions.IgnoreCase); 
     
                    // See if a match is found 
                    if (re.IsMatch(requestedPath)) 
                    { 
                        // match found - do any replacement needed 
                        string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].SendTo)); 
     
                        // log rewriting information to the Trace object 
                        app.Context.Trace.Write("ModuleRewriter", "Rewriting URL to " + sendToUrl); 
     
                        // Rewrite the URL 
                        RewriterUtils.RewriteUrl(app.Context, sendToUrl); 
                        break;        // exit the for loop 
                    } 
                } 
    将 string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].LookFor) + "$"; 改成了 string lookFor = "^" + rules[i].LookFor + "$"; 
    完成这2处改动之后重新编译项目,将生成的dll复制到bin目录下。 再就是写web.config里的重写正则了 <RewriterRule>
                <LookFor>http://(\d+)\.abc\.com</LookFor>
                <SendTo>/show\.aspx?id=$1</SendTo>
            </RewriterRule>好了大功告成,你在IE地址栏输入http://1234.abc.com/,就可以看到http://www.abc.com/show.aspx?id=1234的结果了 http://380326576.qzone.qq.com/