Calendar

March 2010
S M T W T F S
« Feb    
 123456
78910111213
14151617181920
21222324252627
28293031  

Add-on Domains in Shared Web Hosting

Previously, I used some scripts to meet the requirements of hosting several websites in one share hosting plan. This normally requires URL redirection in several sub-folders, which are accessible for the main domain if you know the exact folder name. Besides, from SEO point of view, all websites share the same usage.

However, the domain add-on [...]

Using Proper Header Redirects In PHP

This article is extracted from http://mattiasgeniar.be/2008/07/30/using-proper-header-redirects-in-php/

Let’s say you have an old web-page that’s no longer in use. Of course, you’ll want to redirect your users to the correct (new) page. Using PHP, you can modify the headers of a web-page to redirect them to the correct page.

<?php
header("Location: http://www.mydomain.com/newpage.html");
exit();
?>

This will cause the user who visits the [...]

Share a virtual host with several domains

 1. ASP 空间
- virtual host hosts several domains: index.asp

方法其实很简单,就是利用一个asp文件通过浏览器输入的域名,判定他是要打开那个文件夹里的站点,来实现一个虚拟放置多个站点。
其他说明:如果虚拟主机不支持子目录绑定,这是唯一有效的办法

实现方法如下:
可以这样,你先建立一个默认主页index.asp
然后把A站放在A文件夹下
B站放在B文件夹下
C站放在C文件夹下
index.asp网页文件如下
<%if Request.ServerVariables(“SERVER_NAME”)=”www.a.com ” then
response.redirect “a/index.asp”
elseif Request.ServerVariables(“SERVER_NAME”)=”www.b.com ” then
response.redirect “b/index.asp”
elseif Request.ServerVariables(“SERVER_NAME”)=”www.c.com ” then
response.redirect “c/index.asp”
else
response.redirect “aaa/index.asp”
end if%>
如果用户访问 www.a.com 程序跳转至 空间目录下 a/index.asp
如果用户访问 www.b.com 程序跳转至 空间目录下 b/index.asp
如果用户访问 www.c.com 程序跳转至 空间目录下 c/index.asp
如果用户访问 没有指定的 程序跳转至 空间目录下 aaa/index.asp
怎么样,简单吧?

2. PHP空间
- virutal host hosts several domains: index.php

这是一段很有用的代码,和绑定多域名的ASP代码类似,如果你只有一个PHP空间,而你又想放置多个多个站点,下面这些代码可以帮到你。

第一个:

if($HTTP_HOST==”www.exp-china.com“){
Header(“Location: index.htm”);
}
elseif($HTTP_HOST==”a.exp-china.com”){
Header(“Location: a.htm”);
}
else{
Header(“Location: other.htm”);
}

第二个:

if($HTTP_HOST==”www.exp-china.com“){
require “index.htm”;
}
elseif($HTTP_HOST==”a.exp-china.com”){
require “a.htm”;
}
else{
require “other.htm”;
}

 

OR: 实现方法如下:

先建立一个默认主页index.php
然后把A站放在A文件夹下
B站放在B文件夹下
C站放在C文件夹下

index.php网页文件如下
<?php
switch ($_SERVER["HTTP_HOST"])
{
case “www.a.com”:
header(“location:a/index.php”);
break;
case [...]