ASP.NET网站如何实现不同域名解析不同的子目录
2016-01-25 16:15
615 查看
准备在自己的主机里引用多个域名,先找点资料
著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
作者:玉成
链接:https://www.zhihu.com/question/26014907/answer/31856727
来源:知乎
下面的是ASP的代码,你可以考虑一下:
著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
作者:玉成
链接: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" then response.redirect "blog/index.asp" else response.redirect "index2.asp" end if %> 第二个程序代码 <% select case request.servervariables("http_host") case "www.nuobg.com" '1 Server.Transfer("v3.htm") case "www.jwzjs.com" '2 Server.Transfer("i.htm") case "www.abcwj.com" '3 Server.Transfer("write100.htm") ...... 继续添加 ...... end select %> 第三个程序代码 <% if instr(Request.ServerVariables("SERVER_NAME"),"www.nuobg.com")>0 then response.redirect "index.asp" elseif instr(Request.ServerVariables("SERVER_NAME"),"www.jwzjs.com")>0 then response.redirect "x/index.asp" elseif instr(Request.ServerVariables("SERVER_NAME"),"www.abcwj.com")>0 then response.redirect "index3.asp" end if %> 第四个 程序代码 <% if Request.ServerVariables("SERVER_NAME")="www.nuobg.com" then response.redirect "index1.asp" elseif Request.ServerVariables("SERVER_NAME")="www.jwzjs.com" then response.redirect "index2.asp" elseif Request.ServerVariables("SERVER_NAME")="www.abcwj.com" then response.redirect "index3.asp" end if %> 第五个程序代码 <% if Request.ServerVariables("SERVER_NAME")="www.nuobg.com" then Server.Transfer("williamlong.htm") elseif Request.ServerVariables("SERVER_NAME")="www.jwzjs.com" then Server.Transfer("moon.htm") elseif Request.ServerVariables("SERVER_NAME")="www.abcwj.com" then Server.Transfer("write100.htm") else Server.Transfer("other.htm") end if %>
相关文章推荐
- asprintf
- Owin管道与asp.net管道模型
- Asp.Net前台调用后台变量的方法
- ASP与ASP.NET的区别与比较
- ASP.NET网站管理工具无法连接SQL&amp;n…
- Asp.net原理:Asp.net管道&nbsp;(…
- ASP.NET MVC4.0+EF+LINQ+bui+网站+角色权限管理系统(5)
- ASP.NET学习路线图(入门)
- Asp.Net 文件加解密
- Asp.Net 启用全局IE兼容模式
- 提高 ASP.NET Web 应用性能
- ASP
- 【转】 (C#)利用Aspose.Cells组件导入导出excel文件
- 详解 ASP.NET异步
- 提高 ASP.NET Web 应用性能的 24 种方法和技巧
- ASP.Net基础知识积累
- asp.net网站500.19错误的解决办法
- ASP.NET性能优化
- asp.net mvc多条件+分页查询解决方案
- 1.Getting Started with ASP.NET MVC 5