[string global_cpnav_top]
设为首页收藏本站[string global_cpnav_extra1]
[string global_cpnav_extra2]切换到宽版
[ad headerbanner/wp a_h]

 找回密码
 立即注册
[string global_login_extra]

QQ登录

只需一步,快速开始

[ad subnavbanner/a_mu]
搜索
[string global_header]
[string viewthread_top] [ad text/wp a_t]
返回列表 发新帖[string viewthread_postbutton_top]
[string viewthread_beginline]
查看: 6479|回复: 1

同一个空间绑定多个域名的自动跳转ASP代码

[复制链接] [string viewthread_title_extra]
[string viewthread_title_row]
[array viewthread_avatartop/0]
[array viewthread_avatar/0]
  • 打卡等级:本地老炮
[array viewthread_sidetop/0]

9337

威望

7452

金钱

1万

贡献

管理员

自由的灵魂

积分
107438
主题
5631
回帖
26662
注册时间
2003-4-10
最后登录
2026-10-2
[array viewthread_sidebottom/0]
发表于 2006-3-30 13:22:12 | 显示全部楼层 |阅读模式 [array viewthread_postheader/0]
[ad thread/a_pt/2/0]
[array viewthread_posttop/0]
[ad thread/a_pr/3/0]

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册 [string global_login_text]

×
同一个空间绑定多域名的ASP代码(五个)

第一个
  1. <%if Request.ServerVariables("SERVER_NAME")="www.yyjs.com" then
  2. response.redirect "zkj"
  3. else
  4. response.redirect "i.htm"
  5. end if%>
复制代码
第二个
  1. <%
  2. select case request.servervariables("http_host")
  3. case "www.yyjs.com" '1
  4. Server.Transfer("v3.htm")
  5. case "www.aspcn.net" '2
  6. Server.Transfer("i.htm")
  7. case "www.yyjs.cn" '3
  8. Server.Transfer("yyjs.htm")
  9. ...... 继续添加 ......
  10. end select
  11. %>
复制代码
第三个
  1. <%if instr(Request.ServerVariables
  2. ("SERVER_NAME"),"kekexi.com")>0 then
  3. response.redirect "index.asp"
  4. else if instr(Request.ServerVariables
  5. ("SERVER_NAME"),"4668.com")>0 then
  6. response.redirect "x/index.asp"
  7. else if instr(Request.ServerVariables
  8. ("SERVER_NAME"),"web315.com")>0 then
  9. response.redirect "index3.asp"
  10. end if
  11. end if
  12. end if%>
复制代码
第四个
  1. <%if Request.ServerVariables("SERVER_NAME")="www.yyjs.com" then
  2. response.redirect "index1.asp"
  3. else if Request.ServerVariables("SERVER_NAME")="www.ce.org.cn" then
  4. response.redirect "index2.asp"
  5. else if Request.ServerVariables("SERVER_NAME")="www.163.com" then
  6. response.redirect "index3.asp"
  7. end if
  8. end if
  9. end if%>
复制代码
第五个
  1. <%if Request.ServerVariables("SERVER_NAME")="bob.zhangtao.org" then
  2. response.redirect "bob/"
  3. else%>
  4. <%end if%>
  5. <%if Request.ServerVariables("SERVER_NAME")="009.zhangtao.org" then
  6. response.redirect "009/"
  7. else%>
  8. <%end if%>
  9. <%if Request.ServerVariables("SERVER_NAME")="0431.zhangtao.org" then
  10. response.redirect "0431/"
  11. else%>
  12. <%end if%>
复制代码
[array viewthread_postbottom/0]
不懂就搜!点此搜点拨论坛。如果本坛没有,请尝试点此问AI,或跟帖提问。
发帖前注意看置顶帖。
不定期借助AI对点拨论坛陈年老帖进行挖坟回复,打扰勿怪!
[array viewthread_postsightmlafter/0][ad thread/a_pb/1/0]
学然后知不足,教然后知困。知不足,然后能自反也;知困,然后能自强也。故曰:教学相长也。
回复 [array viewthread_postfooter/0]

使用道具 举报 [array viewthread_postaction/0]

[ad interthread/a_p/0]
[array viewthread_endline/0]
[array viewthread_avatartop/1]
[array viewthread_avatar/1]
  • 打卡等级:本地老炮
[array viewthread_sidetop/1]

9337

威望

7452

金钱

1万

贡献

管理员

自由的灵魂

积分
107438
主题
5631
回帖
26662
注册时间
2003-4-10
最后登录
2026-10-2
[array viewthread_sidebottom/1]
 楼主| 发表于 2006-3-30 14:08:03 | 显示全部楼层 [array viewthread_postheader/1]
[ad thread/a_pt/2/1]
[array viewthread_posttop/1]
[ad thread/a_pr/3/1]用asp一个空间绑多个域名,域名跳转 不修改IIS就可以随便给空间不同文件夹绑上不同的域名

是不是很酷呢?

Apache是很容易实现的了,关键是IIS要实现这个功能就必须为不同文件夹建立不同主机头

虚礼主机商是不允许这么做的.

耍点小聪明,通过以下代码就可以轻松解决.

以下是代码,附注释.
  1. <%
  2. host=lcase(request.servervariables("HTTP_HOST")) '(取得HTTP输入的值并付值到HTOST中)
  3. select CASE host '(开始条件跳转)
  4. CASE "blog.siyizhu.com" '(如果HOST的值是 blog.siyizhu.com 就选择事件case"blog.siyizhu.com"的命令)
  5. response.redirect "/blog/"       ' (转到指定的music目录)
  6. CASE "siyizhu.com/temp/time.htm"   '(如果HOST的值是 blog.siyizhu.com 就选择事件case"siyizhu.com/temp/time.htm"的命令)
  7. response.redirect "temp/time.htm"   ' (转到指定的temp/time.htm文件)
  8. CASE ELSE     '(如果不在上述特定范围)
  9. response.redirect "/bbs/"     '(转到bbs目录)
  10. END select
  11. %>
复制代码
具体做法:

转向的域名需要先绑定到空间的IP,要转几个就要绑几个.
假设你的空间默认首页为INDEX.ASP,将代码添加到INDEX.ASP文件的头部.
上传就OK了
[array viewthread_postbottom/1]
不懂就搜!点此搜点拨论坛。如果本坛没有,请尝试点此问AI,或跟帖提问。
发帖前注意看置顶帖。
不定期借助AI对点拨论坛陈年老帖进行挖坟回复,打扰勿怪!
[array viewthread_postsightmlafter/1][ad thread/a_pb/1/1]
学然后知不足,教然后知困。知不足,然后能自反也;知困,然后能自强也。故曰:教学相长也。
回复 顶 踩 [array viewthread_postfooter/1]

使用道具 举报 [array viewthread_postaction/1]

[ad interthread/a_p/1]
[array viewthread_endline/1]
[string viewthread_middle]
[string viewthread_fastpost_side] [string viewthread_fastpost_content]
[string viewthread_fastpost_func_extra]高级模式 [string viewthread_fastpost_ctrl_extra]
您需要登录后才可以回帖 登录 | 立即注册 [string global_login_text]

本版积分规则 [string viewthread_fastpost_btn_extra]

[string viewthread_bottom]
[ad footerbanner/wp a_f/1][ad footerbanner/wp a_f/2][ad footerbanner/wp a_f/3][ad float/a_fl/1][ad float/a_fr/2][ad couplebanner/a_fl a_cb/1][ad couplebanner/a_fr a_cb/2][ad cornerbanner/a_cn][string global_footer]

QQ|手机版|小黑屋|点拨论坛 [string global_footerlink]|网站地图

GMT+8, 2026-10-2 13:38 , Processed in 0.042689 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表