我想实现这个功能:
如果输入的网址有二级域名,并且和指定的二级域名匹配,那么,就跳转到指定目录下,例如:
网址:bbs.xxx.com
跳转至:www.xxx.com/bbs/
不匹配的话,就按照原样访问。可是,我实现出来的效果是这样的:
网址:bbs.xxx.com
跳转至:www.xxx.com/bbs/
跳转至:www.xxx.com/index.html
这就奇怪了,进入www.xxx.com/bbs/里怎么还是根目录的index.php在响应?
我个人认为应该是打开www.xxx.com/bbs/里面的index.html或index.php。

解决方案 »

  1.   

    无代码无真相.
    另外你的bbs下是不是还有个索引文件index.php...
      

  2.   

    检测一下cgi的变量就行。把phpinfo的资料分析一下,然后在index的最开始检测、跳转。
      

  3.   

    是不是你的apache 服务器 路径没有设置好。
      

  4.   

    PHP语言 我是个傻蛋 需要学习的 更需要懂得完善程序的PHP程序员兼职帮我,在家兼职 你一样可以赚钱
      

  5.   

    建议修改apache的服务路径设置,
      

  6.   

    是不是与.htaccess文件有关系?
    内容如下: <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule># BEGIN WordPress# END WordPress
      

  7.   

    代码如下:<?php
    $host = $_SERVER['HTTP_HOST'];
    if($pos = strpos($host, '/'))
    $domain = substr($host, 0, $pos); // 获取前面一段域名 
    else 
    $domain = $host;

    $count = substr_count($domain, '.', 0);// 计算'.'出现次数
    printf("count:%d<br>", $count);
    if($count == 1) // 如果只有一个'.'  
    header("location: http://{$host}/index.html"); 
    else if($count == 2)
    {
    $temp_str = substr($host, 0, strpos($host, '.')); 
    if(strcasecmp("www", $temp_str) == 0) 
    header("location: http://www.xxxx.com/index.html"); 
    else if(strcasecmp("blog", $temp_str) == 0) 

    /**
     * front to the wordpress application. this file doesn't do anything, but loads
     * wp-blog-header.php which does and tells wordpress to load the theme.
     *
     * @package wordpress
     */ /**
     * tells wordpress to load the wordpress theme and output it.
     *
     * @var bool
     */
    define('wp_use_themes', true); /** loads the wordpress environment and template */
    require('./blog/wp-blog-header.php');
    //header("location: http://www.xxxx.com/blog/"); 
    }
    else if(strcasecmp("bbs", $temp_str) == 0)
    {
    header('location: http://lcui.org/bbs/');
    }
    else {
    header("location: http://{$host}/index.html"); 
    }
    }
    else 
    hearder("location: http://{$host}/index.html");
    ?>
      

  8.   

    printf 是调试这个php时加的。
      

  9.   

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>这是重写了个什么我怎么看不懂
      

  10.   

    这个是设置WordPress的时候,它给的,说要我手动修改.htaccess文件,把它给的内容写进.htaccess文件内,主要是实现固定链接,和Discuz!的伪静态url地址类似。
    这是WordPress给出的相关内容:
    WordPress 默认使用带有很多问号和数字的 URL,但 WordPress 允许自定义链接形式,以提高美感、可用性和向前兼容性。您可阅读参考资料以了解更多。
    若您的 .htaccess 文件可写,我们可以自动修改它。但似乎它不可写,因此我们在下方列出了您 .htaccess 文件中应该加入的 URL 重写规则。点击下方的文本区域,按 CTRL + a 来全选。
      

  11.   

    discuz的设置问题,我在它后台把相关联的域名设置为空,保存后,就正常了。