导航:首页 > IDC知识 > c二级域名绑定目录

c二级域名绑定目录

发布时间:2021-03-03 12:49:21

1、如何绑定子域名(二级域名)到子目录?

具体操作步骤如下:
1、进入思跃主机控制面板,点击“子域名管理”;内
2、输入您要绑定的子域名,容例如:输入blog.domain.com即可绑定blog目录。
3、您绑定的子域名会自动对应网站根目录下的同名目录。(例如:您绑定了blog.domain.com,如果您的根目录下已有blog目录,那么系统在绑定blog目录后,还将会自动生成一个index.html,放在您的blog目录下,您在绑定后直接删除此文件即可;如果您的根目录下没有对应目录,那么系统会自动生成一个blog目录来对应您绑定的子域名)
注意:思跃主机控制面板不支持顶级域名绑定子目录。

2、二级域名如何绑定到网站目录

先建好目录,在绑定域名时指定这个目录,二级域名同时要解析到这个服务器的IP。

3、如何用二级域名绑定子目录

方案1.
Ftp根目录建立一个新的目录test(第二个站)
将xx.xx.com绑定至主站
写一个脚本,
规则: 一旦访问xx.xx.com 自动跳转 访问根目录下的test目录。

方案2.
同样创建test文件夹
以xx.com/test的方式访问

4、二级域名绑定子目录-子目录绑定数量-网站子目录绑...

二级域名绑定子目录-子目录绑定数量-网站子目录绑...
个需要设置一个功能,也就是robots.txt(搜索引擎协议)第一个网站上面的robots.txt里面写上屏蔽搜索引擎抓取你的子目录名,
robots.txt格式为
User-agent:*
Disallow: /zml/

User-agent:*是代表所有搜索引擎(即所有搜索引擎都不允许抓取一下内容)
Disallow: /zml/ zml就是你的那个子目录名字,意思就是不允许搜索引擎抓取查看这个目录下的所有内容
参考资料:

5、设置二级域名,指向特定目录或者文件,如何操作?

到IIS里新建一个网站,然后把主目录设置为你要的目录,再设置一下主机头,就OK了

补充:你如果不能对IIS操作,那只能用URL跳转来实现

6、net 二级域名绑定子目录如何实现

要实现这个功能,首先要做域名泛解析,去域名管理里面的域名解析中添加一个:*.worldbao.com 指向服务器ip。

第二,重写URLRewrite里面的两个方法。

1.BaseMoleRewriter.cs 里面的BaseMoleRewriter_AuthorizeRequest方法



[c-sharp] view plaincopy
protected virtual void BaseMoleRewriter_AuthorizeRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication) sender;
Rewrite(app.Request.Path, app);
}
[c-sharp] view plaincopy
protected virtual void BaseMoleRewriter_AuthorizeRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication) sender;
Rewrite(app.Request.Path, app);
}
改为

[c-sharp] view plaincopy
protected virtual void BaseMoleRewriter_AuthorizeRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication) sender;
Rewrite(app.Request.Url.AbsoluteUri, app);
}
[c-sharp] view plaincopy
protected virtual void BaseMoleRewriter_AuthorizeRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication) sender;
Rewrite(app.Request.Url.AbsoluteUri, app);
}

2, MoleRewriter.cs 里面的 Rewrite 方法



[c-sharp] view plaincopy
protected override void Rewrite(string requestedPath, System.Web.HttpApplication app)
{
// log information to the Trace object.
app.Context.Trace.Write("MoleRewriter", "Entering MoleRewriter");

// get the configuration rules
RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

// iterate through each rule...
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("MoleRewriter", "Rewriting URL to " + sendToUrl);

// Rewrite the URL
RewriterUtils.RewriteUrl(app.Context, sendToUrl);
break; // exit the for loop
}
}

// Log information to the Trace object
app.Context.Trace.Write("MoleRewriter", "Exiting MoleRewriter");
}
}
[c-sharp] view plaincopy
protected override void Rewrite(string requestedPath,
System.Web.HttpApplication app)
{
// log information to the Trace object.
app.Context.Trace.Write("MoleRewriter", "Entering MoleRewriter");

// get the configuration rules
RewriterRuleCollection rules =
RewriterConfiguration.GetConfig().Rules;

// iterate through each rule...
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("MoleRewriter", "Rewriting URL to " +
sendToUrl);

// Rewrite the URL
RewriterUtils.RewriteUrl(app.Context, sendToUrl);
break; // exit the for loop
}
}

// Log information to the Trace object
app.Context.Trace.Write("MoleRewriter", "Exiting MoleRewriter");
}
}
改为

[c-sharp] view plaincopy
protected override void Rewrite(string requestedPath, System.Web.HttpApplication app)
{
// log information to the Trace object.
app.Context.Trace.Write("MoleRewriter", "Entering MoleRewriter");

// get the configuration rules
RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

// iterate through each rule...
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("MoleRewriter", "Rewriting URL to " + sendToUrl);

// Rewrite the URL
RewriterUtils.RewriteUrl(app.Context, sendToUrl);
break; // exit the for loop
}
}

// Log information to the Trace object
app.Context.Trace.Write("MoleRewriter", "Exiting MoleRewriter");
}
}
[c-sharp] view plaincopy
protected override void Rewrite(string requestedPath,
System.Web.HttpApplication app)
{
// log information to the Trace object.
app.Context.Trace.Write("MoleRewriter", "Entering MoleRewriter");

// get the configuration rules
RewriterRuleCollection rules =
RewriterConfiguration.GetConfig().Rules;

// iterate through each rule...
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("MoleRewriter", "Rewriting URL to " +
sendToUrl);

// Rewrite the URL
RewriterUtils.RewriteUrl(app.Context, sendToUrl);
break; // exit the for loop
}
}

// Log information to the Trace object
app.Context.Trace.Write("MoleRewriter", "Exiting MoleRewriter");
}
}
就是将

string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].LookFor) + "$";

改成了

string lookFor = "^" + rules[i].LookFor + "$";

完成这过程之后将整个项目重新编译一下。

这些都做完之后,

在webconfig配置里面的
<configSections>里面 添加:

[xhtml] view plaincopy
<section name="RewriterConfig" type="URLRewriter.Config., URLRewriter"/>
[xhtml] view plaincopy
<section name="RewriterConfig" type="URLRewriter.Config., URLRewriter"/>
在</configSections>下面添加

[xhtml] view plaincopy
<RewriterConfig>
<!-- 处理默认首页失败-->
<Rules>
<RewriterRule>
<LookFor>http://www/.worldbao/.com/</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
</Rules>
<!-- 处理默认首页失败-->

<!--二级域名正则-->
<Rules>
<RewriterRule>
<LookFor>http://([a-zA-Z|0-9]+)/.worldbao/.com/</LookFor>
<SendTo>/user/user.aspx?us=$1</SendTo>
</RewriterRule>
</Rules>
<!--二级域名正则-->
</RewriterConfig>
[xhtml] view plaincopy
<RewriterConfig>
<!-- 处理默认首页失败-->
<Rules>
<RewriterRule>
<LookFor>http://www/.worldbao/.com/</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
</Rules>
<!-- 处理默认首页失败-->

<!--二级域名正则-->
<Rules>
<RewriterRule>
<LookFor>http://([a-zA-Z|0-9]+)/.worldbao/.com/</LookFor>
<SendTo>/user/user.aspx?us=$1</SendTo>
</RewriterRule>
</Rules>
<!--二级域名正则-->
</RewriterConfig>
在httpMoles里面添加

[xhtml] view plaincopy
<httpMoles>
<add type="URLRewriter.MoleRewriter, URLRewriter" name="MoleRewriter"/>
</httpMoles>
[xhtml] view plaincopy
<httpMoles>
<add type="URLRewriter.MoleRewriter, URLRewriter" name="MoleRewriter"/>
</httpMoles>

7、如何绑定二级域名到根目录的某个页面?

在IIS里新建一个网站后绑定一个二级域名:yy.xx.com
然后将这个网站的默认页设置为yy.php,其它删专除即可
----------------------------------------------------------------------------
这个和是属不是php的网站无关,只要你的服务器上的IIS里再添加一个网站,网站目录还是指到原网站目录,再给这个新的网站绑定一个二级域名设置默认页为你想要的页面即可

8、请教如何二级域名绑定子目录

二级域名应该单独开一个站点 指向到你想访问的目录, 你现在的设置是和主站点同时绑定访问,当然显示的是网站根目录啦

与c二级域名绑定目录相关的知识