Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Silex return "The requested URL /home was not found on this server." error message?

Tags:

routing

silex

It is the first time I play with Silex. I've tried a '/' route, in GET and POST, and all works fine. Now I am trying to make more complex requests:

<?php

    require_once __DIR__ . '/../vendor/autoload.php';
    $app = new Silex\Application();
    $app->get(
        '/home',
        function () use ($app) {
            return 'Homepage';
        }
    );
    $app->run();

"/home" route returns "The requested URL /home was not found on this server.". Why?

This is my .htaccess:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FIOLNAME} !-f
RewriteRule ^ index.php [L]

"/index.php/home" works

like image 599
sensorario Avatar asked Dec 02 '22 18:12

sensorario


2 Answers

Try index.php/home. If that works you are missing the .htaccess (on Apache).

Take a look here http://silex.sensiolabs.org/doc/web_servers.html

like image 149
xmarcos Avatar answered Jan 17 '23 16:01

xmarcos


This should do the work :

$ sudo a2enmod rewrite
$ sudo service apache2 restart
like image 38
Favian Ioel P Avatar answered Jan 17 '23 17:01

Favian Ioel P