想实现的功能如下:一个虚拟空间,三个域名想建立三个网站例如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

解决方案 »

  1.   

    给个例子,应该不难写吧RewriteEngine On   
    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
      

  2.   

    非常感谢楼上的老师测试可以通过返回header如下:
    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
      

  3.   

    刚看到你的消息.对于伪静态什么的写法我也不是很了解.不过你可以这样.
    直接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;
    }
      

  4.   

    RewriteEngine On   
    RewriteCond %{HTTP_HOST} ^www.abc.com [NC]
    RewriteRule ^(.*) http://www.baidu.cn/a/index.htm [L,R=301]  用301可能对seo影响不大
      

  5.   

    phpwind的也是重定向为什么是200ok不是301啊?
    http://www.phpwind.net/read-htm-tid-2012599.html
      

  6.   

    200不叫重定向。。浏览器不可能做傻事的,一定是前端ajax控制的重定向。
      

  7.   

    phpwind的也是重定向为什么是200ok不是301啊?
    http://www.phpwind.net/read-htm-tid-2012599.html
      

  8.   

    学习中,其实偶只是PHP的初学者。 偶现在都不做软件这行了。