PHP页面路由,工作在localhost:3000但不在localhost / dir /上

时间:2017-05-25 11:10:27

标签: php url-routing

以下代码段在 localhost:3000 上运行时效果很好但在 localhost / dir / 上运行时停止工作,并且每个事物都显示默认的大小写结果即使是 /

    <?php
    // Grabs the URI and breaks it apart in case we have querystring stuff
    $request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
    // Route it up!
    switch ($request_uri[0]) {
        // Home page
        case '/':
            echo "/ here\n";
            break;
        // About page
        case '/about':
            echo "about.php is opened from here\n";
            break;
        // Everything else
        default:
            header('HTTP/1.0 404 Not Found');
            echo "404 is opened from here \n";
            break;
    }
    ?>

0 个答案:

没有答案