我想实现这个功能:
如果输入的网址有二级域名,并且和指定的二级域名匹配,那么,就跳转到指定目录下,例如:
网址: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。
如果输入的网址有二级域名,并且和指定的二级域名匹配,那么,就跳转到指定目录下,例如:
网址: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。
另外你的bbs下是不是还有个索引文件index.php...
内容如下: <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
$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");
?>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>这是重写了个什么我怎么看不懂
这是WordPress给出的相关内容:
WordPress 默认使用带有很多问号和数字的 URL,但 WordPress 允许自定义链接形式,以提高美感、可用性和向前兼容性。您可阅读参考资料以了解更多。
若您的 .htaccess 文件可写,我们可以自动修改它。但似乎它不可写,因此我们在下方列出了您 .htaccess 文件中应该加入的 URL 重写规则。点击下方的文本区域,按 CTRL + a 来全选。