phpwampserveraltorouter

Using Alto Router in wamp server


Hi i want to use the package called Alto Router in wamp.

in www root i changed the index page with

<?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');

    }

Redirection of home page is Ok But if i type localhost/page1 it redirects to 404 error page.. I think this is because of the default wamp server settings etc.. İs there anyway to change it?


Solution

  • After discussion in comments -

    The 500 error tells us that the .htaccess is now being used, so that's good.

    The first thing to try is checking that the URL rewriting module is enabled.

    Click the WAMP tray icon and navigate to Apache -> Apache Modules -> scroll to rewrite_module and turn that on (check mark)

    rewrite module