導航:首頁 > 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二級域名綁定目錄相關的知識