Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing problems
  • I'm having problems with my routing on a new website I'm setting up. Having been going round and round in circles, I believe what is happening is that on the shared hosting, all routes get directed to the 'index' action of the relevant controller (it's fine on my localhost).

    Having already had problems with the hosting people (suhosin blocking the composer.phar update, and Apache environment variables not being passed to PHP), I suspect the hosting config, but I've no idea how to go about debugging the routing - have you any suggestions?

    Thanks, Chris
  • So it does route to the correct controller, but only to the index action of that controller?

    That is odd, since both action and controller are URI segments, I don't see how one can work and the other one not.
  • Oooh, this was a tricky one – a bit of distance and a fresh approach helped, together with         Debug::dump(Uri::main(), Uri::current()) in the 404 controller.

    To enable hyphens in URLs, my config 'security' array includes
        'uri_filter' => array(
            'htmlentities',
            // enable hyphens in URLs: stackoverflow.com/questions/11652447
            function($uri) {
                return str_replace(' ', '', ucwords(str_replace('-', ' ', $uri)));
            },
        ),

    On my localhost (and other servers) the $uri parameter includes a leading '/'; but on the shared hosting I'm using for the current project, it does not; this meant that the first letter of the URI got capitalised by the call to ucwords(), hence breaking the routing. I've fixed it with a call to lcfirst().

    I have no idea why that would have enabled it to route to the 'index' action (that was clearly something of a red herring), but do you have any idea why the $uri parameter might vary on different servers (with or without leading '/'), Harro?

    Thanks for your help,

    Chris
  • Can you check on your shared server, in Input::uri(), what mechanism is used to determine the URI?

    And what kind of PHP installation is used (webserver, php-sapi, mpm or fcgi)?
  • How would I the mechanism to determine the URI? Is it in the Input::uri() array?

    The installation is FastCGI:

    Server APICGI/FastCGI
  • Yes.

    If you use the standard .htaccess, you have the correct rewrite rules for FCGI installations.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion