一个类似blog的php站点,用户注册后只需输入
http://www.test.com/用户名 即可到达他们自己的子站点页面是不是可以把http://www.test.com/user.php?uid=用户ID
用rewrite解析成http://www.test.com/用户ID/ 具体要怎么配置实现呢?

解决方案 »

  1.   

    RewriteRule /([0-9]+) user.php?uid=$q
      

  2.   

    RewriteRule ^/(.+)$ /user.php?uid=$1 [PT,L]个人建议,如果你的www.test.com下除了blog还有别的东西的话,最后使用如
    http://blog.test.com/用户名
    进入,不然,apache会把http://www.test.com/index.php变成http://www.test.com/user.php=index.php
      

  3.   

    RewriteRule ^.*/\d+/$ /user.php?uid=$1 [PT,L] 没有经过测试,大致上应该是这样的也就是把/数字/ ,把中间的数据取出来,给成后面一个链接
      

  4.   

    不然,apache会把http://www.test.com/index.php变成http://www.test.com/user.php=index.php======================================
    那样就去掉了上面的顾虑
      

  5.   

    类似RewriteRule ^/(.+)$ /user.php?uid=$1 [PT,L],就是在apache里面设置的
      

  6.   

    你可以参考这个
    都是正则来着
    <FilesMatch "\.(php)$">
    php_value short_open_tag "Off"
    php_value auto_append_file "/mnt/hda5/usr/local/www/html/count.htm"
    </FilesMatch>AddType application/x-httpd-php .htm .html
    <FilesMatch "\.(htm?)$">
    php_value short_open_tag "Off"
    php_value auto_append_file "/mnt/hda5/usr/local/www/html/count.htm"
    </FilesMatch>
    注意:在有的服务器上不能正常处理