Php包含包含mod_rewrite隐藏get变量问题的页面


Php including pages with mod_rewrite hiding get variables issue

我有麻烦让我的mod_rewrite工作,所以链接从http://domain.com/page?home.phphttp://domain.com/home

输入http://domain.com/后,首页显示正确

输入http://domain.com/404http://domain.com/anythinghere, 404页面显示正确

当输入http://domain.com/home时,一个错误500被引发,我得到这个错误:File does not exist: /var/www/html/domain/Dev/home

为什么不工作?

我的项目如下:

目录结构:

Dev/
    .htaccess
    index.php
    menu.php
    pages/
        404.php
        home.php
    resources/
        css/
            core.css
        fonts/

. htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^('d+)*$ ./index.php?page=$1

index . php:

<?php
if ( !isset( $_GET['page'] ) )
    $_GET['page'] = 'home';
$pages = array('home');
$page  = $_GET['page'];
include( 'menu.php' );
if( in_array( $page, $pages ) )
{
    include( 'pages/' . $page . '.php' );
}
else
{
    include( 'pages/404.php' );
}
?>
</body>
</html>

应该重写为:

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