2

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?

  • 1
    Did you setup rewriting as shown [here](http://altorouter.com/usage/rewrite-requests.html)? – danjam Dec 11 '15 at 11:31
  • 1
    Are you in the document root or in a sub directory or your web server? – Progrock Dec 11 '15 at 11:41
  • @danjam In C:\wamp\www\vendor\altorouter\altorouter\examples\basic there is a .htaccess file as shown at the link and i also coppy this the htaccess in C:\wamp\apps\phpsysinfo3.1.12 but there is still the same problem.. –  Dec 11 '15 at 11:49
  • @Progrock I'm in the document root..İ changed the wamp index page as shown in my comment. –  Dec 11 '15 at 11:52
  • The .htaccess should be placed in your document root – danjam Dec 11 '15 at 11:57
  • @danjam at this there occurs "500 Internal Server Error". –  Dec 11 '15 at 12:02

1 Answers1

0

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

danjam
  • 1,064
  • 9
  • 13