2

我有一个非常简单的站点来测试我的在线主机上的 url 重写,因为我的原始应用程序在我的本地 WampServer 上运行良好,但不适用于我的在线主机。

这是我的代码:

索引.php:

    <?php

    $p = $_GET['p'];

    $pages = array (

        'home'      => 'home.php',
        'about'     => 'about.php',
        'contact'   => 'contact.php'

    );

    if (isset($pages[$p]))  $page = $pages[$p];

    else                            $page = 'home.php';

    include $page;

?>



<!doctype html>

<html>

    <head></head>

    <body>

        <?php echo $body; ?>

        <br /><br /><br />

        <a href="http://newcryo.com/">HOME</a> - <a href="http://newcryo.com/about/">ABOUT</a> - <a href="http://newcryo.com/contact/">CONTACT</a>

    </body>

</html>

主页.php:

<?php

    $body = '

        <h1>Home</h1>

        This is the home page

    ';

?>

关于.php:

<?php

    $body = '

        <h1>About</h1>

        This is the about page

    ';

?>

联系方式.php:

<?php

    $body = '

        <h1>Contact</h1>

        This is the contact page

    ';

?>

.ht 访问:

Options +FollowSymLinks

RewriteEngine On



# home
RewriteRule ^$ index.php?p=home [L]

# other pages
RewriteRule ^([^/\.]+)/$ index.php?p=$1 [L]

现在,当 url 为“ http://newcryo.com/ ”时,它会显示主页内容。

但是当“ http://newcryo.com/about/ ”或“ http://newcryo.com/contact/ ”它什么都没有显示并且它直接打开about.php或contact.php而不是index.php中的home页

两者都应该翻译为“ http://newcryo.com/index.php?p=about ”,但在这里它呈现为“ http://newcryo.com/about.php

我的本地主机是带有 PHP 5.4.3 / Apache 2.2.22 的 WampServer 我的远程主机是带有 PHP 5.4 / Apache 2.2.20 的 OVH perso 共享主机

有什么建议吗?谢谢。

4

1 回答 1

2

MultiViews这里可能是个问题。

将您的选项更改为:

Options +FollowSymLinks -MultiViews
于 2013-07-09T17:00:26.993 回答