By meulruben
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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Add the following line to your server block, replacing try_files if it already exits:
try_files $uri $uri/ /index.php?$args;
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.