网址重写打破了我的包含

时间:2014-12-28 09:24:50

标签: php .htaccess url rewrite

我的网址重写有问题让我告诉你,我的代码是: 的index.php:

include 'header.php';

if(!isset($_GET['page']) or !file_exists($_GET['page'] . '.php') {
    include_once 'home.php';
} else {
    include_once $_GET['page'] . '.php';
}

include 'footer.php';

这里的代码适用于/index.php?page=test 但是我的重写网址

RewriteRule ^page/(.*)$ index.php?page=$1 [QSA,L]

这里的代码不能与url / page / test一起使用,问题是他只包含test.php我的页眉和页脚不包括在内,我不知道为什么......

1 个答案:

答案 0 :(得分:0)

听起来像绝对/相对网址问题。当您转到/page/XXXX网址时,您已将相对网址基础从/更改为/page/,因此您需要更改所有链接,以便他们能够绝对URL或在页面标题中包含相对URL基础:

<base href="/" />