Question

LEMP on Ubuntu : 404's everywhere

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04

After following this tutorial I got a working server, I can display the info test page. However if I test my Silex project I encounter 404’s on all my routes (except the “/” route).

class HomeController implements ControllerProviderInterface {

    public function connect(Application $app) {
        $controllers = $app['controllers_factory'];

        $controllers
            ->get('/home/', array($this, 'overview'))
            ->method('GET|POST')
            ->bind('home.overview');

        $controllers->get('/', function(Application $app) {
            //return 'Test'; //Works
            return $app->redirect($app['url_generator']->generate('home.overview')); //Works
        });

        return $controllers;
    }

    public function overview(Application $app) {
        //return $app->redirect($app['url_generator']->generate('auth.register')); //Doesn't work
        return 'test'; //Doesn't work
    }
}

For the code above, the base url (“/”) can show a “test” string or redirect to “/home” which is linked to the overview function. However everything I try in that overview function doesn’t work, I cannot return “test” or redirect to another url, both things that where working in the “/” route.

All of this code works local.

Error log doesn’t help very much.

The 404’s are they because of some bad configuration? Where to look/what to change?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Add the following line to your server block, replacing try_files if it already exits:

try_files $uri $uri/ /index.php?$args;