|
多域名网站按域名跳转
用ASP用判断访问域名的方法来跳转到相应的页面,代码如下: <% if Request.ServerVariables("SERVER_NAME")=www.xxx.com then response.redirect "index.asp" \'如果输入的域名是则跳到首页 elseif Request.ServerVariables("SERVER_NAME")="bbs.xxx.com" then response.redirect "/bbs" \'如果输入的域名是则跳到论坛 else response.redirect http://www.xx.com \'其它域名跳到网站首页 end if %> 将此文件存成网站的默认首页此可 asp和php环境下的根据来访问域名跳转 经常有一个空间支持绑多个域名,但是不支持子目录绑定,而希望根据不同的来访域名访问到不同站点! 这个是一个实现功能简单的小例子,放上来尽是提示一点思路 asp代码 <% if request.serverVariables("server_name")="http://hi.baidu.com/lagger" then response.redirect("/文件夹/") else if request.serverVariables("server_name")="bbs.00qi.com" then response.redirect("/bbs") else response.redirect("/bbs") end if %> js多域名跳转 <script>try {if( self.location == "http://玉米一/" ) { top.location.href = "http://玉米一/目录"; } else if( self.location == "http://玉米二/" ) { top.location.href = "http://玉米二/目录"; } else if( self.location == "http://玉米三/" ) { top.location.href = "http://玉米三/目录"; } else if( self.location == "http://玉米四/" ) { top.location.href = "http://玉米四/目录"; } else {document.write ("错误的访问地址")}} catch(e) {}</script>
========================================================== 按照下面的办法操作: 1、在空间上分别绑定 www.aaa.com 和 www.bbb.com 2、把 www.aaa.com 网站文件传到根目录,把 www.bbb.com 网站传到 ./bbb/ 目录 3、把下面的代码保存为domain.js ,然后上传到空间根目录 switch(location.host){ case 'www.bbb.com': location.href="http://www.bbb.com/bbb/" break; } 4、往空间根目录的首页的 <head> 与 </head> 之间加入 <script language='javascript' src='domain.js'></script> 5、当你输入 www.aaa.com 访问时看不到任何变化,但是当你输入 www.bbb.com 访问时, 浏览器自动跳转到 www.bbb.com/bbb/ 。 这样便实现了同一个空间安装2个网站了,要实现多个网站可以依此类推.
==========================可以使用.asp======================== <% host=lcase(request.servervariables("HTTP_HOST")) SELECT CASE host ' Just change the CASE to your domains CASE "www.XXX.com" ' Below is the redirect command response.redirect "index.asp" CASE "ftp0903.zj35.idc58.net" response.redirect "temp/" CASE ELSE response.redirect "index.Asp" END SELECT %>
辛苦整理@转载请注明:http://www.esw.net.cn/shownews.asp?id=321
更多关于网站建设推荐阅读:
域名跳转代码
显示桌面没了怎么办?
QQ在线咨询显示“未启用”的解决办法
|
|
|
 |
|
|