2

嗨,我想在 wamp 中使用名为 Alto Router 的包。

在 www root 我更改了索引页

<?php
    require( __DIR__ . "/vendor/autoload.php");



    $router = new AltoRouter();

    $router->map('GET','/',function(){
    include(__DIR__ . "/project/home.php");


    });

    $router->map('GET','/page1',function(){
    include(__DIR__ . "/project/page1.php");

    });

    $match = $router->match();

    if($match && is_callable($match['target'])){
    call_user_func_array($match['target'],$match['params']);

    }
    else{
    //no route found
    header($_SERVER['SERVER_PROTOCOL'].'404 Not Found');

    }

主页的重定向是好的,但是如果我输入 localhost/page1 它会重定向到 404 错误页面。我认为这是因为默认的 wamp 服务器设置等。无论如何要改变它吗?

4

1 回答 1

0

在评论中讨论后 -

500 错误告诉我们现在正在使用 .htaccess,这很好。

首先要尝试检查是否启用了 URL 重写模块。

单击 WAMP 托盘图标并导航到 Apache -> Apache Modules -> 滚动到 rewrite_module 并打开它(复选标记)

重写模块

于 2015-12-11T12:26:32.510 回答