想实现的功能如下:一个虚拟空间,三个域名想建立三个网站例如http://a.com
http://b.com
http://c.com想实现:
访问:http://a.com 实际是访问虚拟空间根目录中的:index.htm
访问:http://b.com 实际是访问虚拟空间根目录下b文件夹下的:index.htm
访问:http://c.com 实际是访问虚拟空间根目录下c文件夹下的:index.htm
http://b.com
http://c.com想实现:
访问:http://a.com 实际是访问虚拟空间根目录中的:index.htm
访问:http://b.com 实际是访问虚拟空间根目录下b文件夹下的:index.htm
访问:http://c.com 实际是访问虚拟空间根目录下c文件夹下的:index.htm
RewriteCond %{HTTP_HOST} ^www.abc.com [NC]
RewriteRule ^(.*) http://www.baidu.cn/a/index.htm [L] 访问www.abc.com跳转到http://www.baidu.cn/a/index.htm
HTTP/1.1 302 Found
Keep-Alive:timeout=5, max=100
Connection:Keep-Alive
Content-Length:220
Content-Type:text/html; charset=iso-8859-1
Date:Fri, 27 Apr 2012 02:56:31 GMT
Location:http://www.baidu.cn/taobao/index.htm
Server:Apache/2.2.8 (Win32) PHP/5.2.5但还有个问题想请教一下,上面的返回htt状态码为302这样不太好,是不是可以像phpwind这样返回的状态码为200呢?
如下:
http://www.phpwind.net/read-htm-tid-2012599.html返回:
HTTP/1.1 200 OK
Transfer-Encoding:chunked
Connection:keep-alive
Content-Type:text/html
Date:Fri, 27 Apr 2012 02:58:42 GMT
Set-Cookie:08383_lastpos=T2012599; expires=Sat, 27-Apr-2013 02:58:42 GMT; path=/; domain=.phpwind.net,08383_lastvisit=880%091335495522%09%2Fread.php%3Ftid-2012599.html; expires=Sat, 27-Apr-2013 02:58:42 GMT; path=/; domain=.phpwind.net,08383_ci=deleted; expires=Thu, 28-Apr-2011 02:58:41 GMT; path=/; domain=.phpwind.net,08383_readlog=%2C1144371%2C2012599%2C; expires=Sat, 27-Apr-2013 02:58:42 GMT; path=/; domain=.phpwind.net,08383_ci=read%091335495522%092012599%09131; expires=Sat, 27-Apr-2013 02:58:42 GMT; path=/; domain=.phpwind.net
Server:nginx/1.0.5
Content-Encoding:gzip
hostname:10.249.214.68
Content-Length:33300
直接include 好了.
function curPageURL()
{
$pageURL = 'http'; if (isset($_SERVER["HTTPS"])&&($_SERVER["HTTPS"] == "on")) {
$pageURL .= "s";
}
$pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
}
else {
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
}$url=curPageURL();
switch ($url){
case 'http://a.com':
include 'index.htm';
break;
case 'http://b.com':
include './b/index.htm';
break;
default:
include 'index.htm';
break;
}
RewriteCond %{HTTP_HOST} ^www.abc.com [NC]
RewriteRule ^(.*) http://www.baidu.cn/a/index.htm [L,R=301] 用301可能对seo影响不大
http://www.phpwind.net/read-htm-tid-2012599.html
http://www.phpwind.net/read-htm-tid-2012599.html