Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with either routing or rewrite on production server
  • My app lives in /api/v1/ and I'm getting the following behavior: https://domain.com/api/v1 = I get the correct response for the _root_ route, which is default/index. As expected. https://domain.com/api/v1/index.php = I get the response for the _404_ route, which is default/404. I would expect default/index. https://domain.com/api/v1/default/index = I get a 404 *from apache*. I would expect the page for default/index. Note that this is not the custom 404 response from Fuel...apache never even gets to Fuel, it seems. The error page from apache gives the standard "The requested URL /api/v1/index.php/default/index was not found on this server. Note that I did not put index.php in the URL, but it shows up in the error message, so it would seem that the rewrite rules are working at least somewhat. But what happens then, I'm baffled. Also important: none of this happens on my dev server; the routing all works fine on my dev server. The only difference that I know of is that the dev server is using unencrypted requests and the production server is using SSL. Thanks for any insight anyone might have!
  • https://domain.com/api/v1/index.php would strip the extension, and then look for a controller called "index", and call a method called "index" in that controller. If that doesn't exist, you get a 404. Unless you have a route 'index' => 'default/index', I don't see a reason why it would call the "default" controller. So for me that 404 behaviour is correct. I can't comment on your rewrite rules, because you haven't posted them. What kind of setup has your production server? Running fcgi? Some other non-standard setup? Other setups require different rewrite rules, although the normal fcgi behaviour (with the default htaccess supplied by FuelPHP) is to always load the default page (= ignore any segments).
  • Oddly, the behavior you describe does not occur for my development server. When I call /index.php directly in the browser, FuelPHP routes to _root_ and gives me the default/index action. Which is what I would expect... internally, all requests to the Fuel app are going to look like /index.php/path/to/whatever, no? In any case, no there's nothing special about this server as far as I know. I set it up myself a couple of months ago...it's a completely standard Ubuntu LAMP stack, everything installed via apt-get and no strange config. My dev server is the same, though a slightly older version. The rewrite rules are unaltered FuelPHP 1.2 distribution:
    <IfModule mod_rewrite.c>
        RewriteEngine on
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    

    Since my original post, I have restructured the vhost & app so that the FuelPHP public/ directory is the docroot and the app no longer lives in a subdir. Same problems exist...something is getting very confused somewhere.
    https://domain.com/default/index
    

    results in standard Apache 404 page:
    The requested URL /index.php/default/index was not found on this server.
    

    The fact that "index.php" appears in that path tells me that the rewrite was performed, but why on earth would /index.php/default/index be 404? The index.php file obviously exists! Are there cases where Apache can be confused by "index.php/path/to/whatever"? This all works fine on the dev server. Also, I tried moving the domain to unencrypted port 80, thinking that SSL might have something to do with it. No joy...problem still occurs. Based on what I'm seeing, this isn't actually a FuelPHP problem at this point, but I'm still grateful for any insight anyone can offer.
  • If you only request index.php, it will load the _root_ route, that is true. I think I misread the question. If the URL is correct, perhaps it's a rights issue, and your apache user can't read the index.php? Whether you rewrite or not, a call to http://domain.com/index.php should work and load the default route (due to the condition defined in the .htaccess).

Howdy, Stranger!

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

In this Discussion