1、如何绑定子域名(二级域名)到子目录?
具体操作步骤如下:1、进入思跃主机控制面板,点击“子域名管理”;2、输入您要绑定的版子域权名,例如:输入blog.domain.com即可绑定blog目录。3、您绑定的子域名会自动对应网站根目录下的同名目录。(例如:您绑定了blog.domain.com,如果您的根目录下已有blog目录,那么系统在绑定blog目录后,还将会自动生成一个index.html,放在您的blog目录下,您在绑定后直接删除此文件即可;如果您的根目录下没有对应目录,那么系统会自动生成一个blog目录来对应您绑定的子域名)注意:思跃主机控制面板不支持顶级域名绑定子目录。
2、bch二级目录怎么绑定二级域名
这个就要看您的空间是否支持子目录绑定了
如果支持的话您吧域名绑定到子目录上然后到域名商那做好域名解析即可
如果不支持的话那么这个您只能通过程序代码去实现这个功能比如301跳转
(望楼主采纳哦)
3、dedecms网站二级目录怎么绑定二级域名?
栏目管理里面,在栏目更改里面切换下,有可以启用二级域名的地方,你直接填进去,解析绑定好就可以了,具体的你可以自己看看你的任意一个栏目
4、怎么隐藏二级域名绑定的二级目录?
或者你试试这个方法,把二级域名的解析设置,设为引隐性转发;不过这样打开m.xxx.com下面的所有页面都只显示这一个地址;
5、二级域名如何绑定到网站目录
先建好目录,在绑定域名时指定这个目录,二级域名同时要解析到这个服务器的IP。
6、apache如何实现二级域名绑定子目录
好果是服务器或VPS,修改apache的配置文件httpd.conf ,每一块VirtualHost都是一个网站配置,添加内容如下:
<VirtualHost www.test.com:80> # 网站名和端口
ServerAdmin [email protected] # 管理员邮箱
DocumentRoot "/usr/local/apache/htdocs" #对应绑定的目录
ServerName www.test.com #域名绑定。
ErrorLog logs/www_error_log.txt # 错误日志
CustomLog logs/www_log.txt common
</VirtualHost>
# 下面是二级域名的绑定
<VirtualHost bbs.test.com:80> # 网站名和端口
ServerAdmin [email protected]
DocumentRoot "/usr/local/apache/htdocs/bbs" #对应绑定的目录
ServerName bbs.test.com # 要绑定的二级域名
ErrorLog logs/bbs_error_log.txt
CustomLog logs/bbs_log.txt common
</VirtualHost>
7、请教如何二级域名绑定子目录
二级域名应该单独开一个站点 指向到你想访问的目录, 你现在的设置是和主站点同时绑定访问,当然显示的是网站根目录啦
8、如何用二级域名绑定子目录
方案1.
Ftp根目录建立一个新的目录test(第二个站)
将xx.xx.com绑定至主站
写一个脚本,
规则: 一旦访问xx.xx.com 自动跳转 访问根目录下的test目录。
方案2.
同样创建test文件夹
以xx.com/test的方式访问
9、网站二级目录怎么绑定二级域名?IIS主机
首先需要你的域名服务器允许添加二级域名目录,操作起来和一级域名的一样,如果允许操作,再设定个首页访问就可以了
10、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>