ASP.NET网站如何实现不同域名解析不同的子目录

来源:互联网 发布:淘宝搜索暗语大全 编辑:程序博客网 时间:2024/05/02 01:31

准备在自己的主机里引用多个域名,先找点资料

著作权归作者所有。

商业转载请联系作者获得授权,非商业转载请注明出处。
作者:玉成
链接:https://www.zhihu.com/question/26014907/answer/31856727
来源:知乎

这是一段很有用的代码,和绑定多域名的ASP代码类似,如果你只有一个PHP空间,而你又想放置多个多个站点,下面这些代码可以帮到你第一个:程序代码if($HTTP_HOST=="www.nuobg.com"){Header("Location: index.htm");}elseif($HTTP_HOST=="www.jwzjs.com"){Header("Location: wiljwzjs.htm");}else{Header("Location: other.htm");}第二个:程序代码if($HTTP_HOST=="www.nuobg.com"){require "moon.htm";}elseif($HTTP_HOST=="www.jwzjs.com"){require "williamlong.htm";}else{require "other.htm";}二用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>
下面的是ASP的代码,你可以考虑一下:
如果只有一个ASP空间,而你又想放置多个多个站点,这些代码可以帮到你第一个 程序代码<%if Request.ServerVariables("SERVER_NAME")="www.nuobg.com" thenresponse.redirect "blog/index.asp"elseresponse.redirect "index2.asp"end if%>第二个程序代码<%select case request.servervariables("http_host")case "www.nuobg.com" '1Server.Transfer("v3.htm")case "www.jwzjs.com" '2Server.Transfer("i.htm")case "www.abcwj.com" '3Server.Transfer("write100.htm")...... 继续添加 ......end select%>第三个程序代码<%if instr(Request.ServerVariables("SERVER_NAME"),"www.nuobg.com")>0 thenresponse.redirect "index.asp"elseif instr(Request.ServerVariables("SERVER_NAME"),"www.jwzjs.com")>0 thenresponse.redirect "x/index.asp"elseif instr(Request.ServerVariables("SERVER_NAME"),"www.abcwj.com")>0 thenresponse.redirect "index3.asp"end if%>第四个程序代码<%if Request.ServerVariables("SERVER_NAME")="www.nuobg.com" thenresponse.redirect "index1.asp"elseif Request.ServerVariables("SERVER_NAME")="www.jwzjs.com" thenresponse.redirect "index2.asp"elseif Request.ServerVariables("SERVER_NAME")="www.abcwj.com" thenresponse.redirect "index3.asp"end if%>第五个程序代码<%if Request.ServerVariables("SERVER_NAME")="www.nuobg.com" thenServer.Transfer("williamlong.htm")elseif Request.ServerVariables("SERVER_NAME")="www.jwzjs.com" thenServer.Transfer("moon.htm")elseif Request.ServerVariables("SERVER_NAME")="www.abcwj.com" thenServer.Transfer("write100.htm")elseServer.Transfer("other.htm")end if%> 
0 0
原创粉丝点击