一个空间制作2站点绑定2个域名的方法

2007年4月30日 / 其他转载 / 1条 / 2,817次

在同一个虚拟空间内放置2个不同的站点,并同时可使用2个域名访问各自的站点,方法如下:

1、首先确保空间支持asp,开通虚拟空间时要求空间商绑定2个域名到空间,如有FTP控制面板可自行添加域名的话那是最好;

2、在空间根目录分别开2个文件夹如aa和bb,用于放置2个不同的站点;

3、将以下代码建立index.asp文件,上传至空间根目录即可。

 

 程序代码
<%if Request.ServerVariables("SERVER_NAME")="aa.com" then  '第一个输入的网址
response.redirect "aa/index.htm"                                             '将它转发到相应的文件夹
else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="www.aa.com" then 
response.redirect "aa/index.htm"                         
else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="bb.com" then   '第二个输入的网址
response.redirect "bb/index.htm"                                               '将它转发到相应的文件夹
else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="www.bb.com" then
response.redirect "bb/index.htm"
else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="www.aa.com/" then 
response.redirect "aa/index.htm"                         
else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="bb.com/" then   '第二个输入的网址
response.redirect "bb/index.htm"                                               '将它转发到相应的文件夹
else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="www.bb.com/" then
response.redirect "bb/index.htm"
else%>

<%end if%>

由于考虑到输入的网子后面有/与没有/的区别,所以,得建立有/和没有/的转向!

也可以在根目录下创建两个不同的通常默认页面,比如:index.htm,index.html之类的。
然后把上面的bb/index.htm和aa/index.htm分别修改成index.htm,index.html,这样当访问你不同的玉米时候,就可以变成“你的a玉米/index.htm”或者“你的b玉米/index.html”。

效果请看:https://long.gehttp://www.jo-anna.cn

原文网址:http://localhost/article.asp?id=292


《一个空间制作2站点绑定2个域名的方法》有1条评论


770940623 留言