www.21.com/user/index.php?user=cngothic
伪静态成
cngothic.21.com使用下面正则RewriteCond Host: (?!www|bbs)([^.]+)\.21\.com
RewriteRule (.*) /user/index\.php\?user=$1然后
www.21.com/user/addnew.php?user=cngothic
伪静态成
cngothic.21.com/add.html这个怎么写正则尼。试了很多。只要写cngothic.21.com/**** 都是访问 /user/index\.php\?user=$1求助。希望我描述的大家能看懂。

解决方案 »

  1.   

    二级域名是不能用rewrite实现的
    rewrite只能实现
    比如:www.21.com/index.php?user=cng ->  www.21.com/cng.htm
    也就是说rewrite不能改变前面的www.21.com我做二级域名是这样实现的:
    首先在服务器上配置个泛域名
    也就是确保你访问a.b.c.21.com都能访问你的www.21.com
    其中a,b,c是任意的字符
    然后在www.21.com/index.php里对应程序里写:(假设你的默认访问文件是index.php)$url=$_SERVER["HTTP_HOST"];
    //echo $url;
    $a = explode(".",$url);
    $b = count($a);

    if($b>1)
    {
    if($a[0]== "game")
    {
    $c = "game/index.html";
    $d = file_get_contents($c);
    }
    else if($a[0]== "gouwu")
    {
    $c = "game/index.html";
    $d = file_get_contents($c);
    } echo $d;
    }
    else
    {
    //$c = "http://localhost:8001/infolist.php";
    $c = "http://localhost:8001/index.shtml";
    $d = file_get_contents($c);
    echo $d;
    }
    把获得的地址,分开,然后用file_get_content()抓取,这样内容就变了,地址不会变
      

  2.   

    二级域名是不能用rewrite实现的 
    rewrite只能实现 
    比如:www.21.com/index.php?user=cng ->  www.21.com/cng.htm 
    rewrite肯定可以实现二级域名啊。你上面所说的方面会存在一个问题中。
    例:打开 abc.21.com ie上显示的url是 www.21.com/user/index.php?user=abc
      

  3.   

    到官方发了帖子。老外回的。Please try to use the following: RewriteCond Host: (?!www|bbs)([^.]+)\.21\.com 
    RewriteRule (?:/add\.html)? /user/(?1add.asp:index.asp)\?user=$1add.html生效了。但index.asp失。设置多个页面时只胡最尾的那个页面能request到值