Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
nginx rewrite php file to fuelphp
  • Hi,

    I want to do this:

    - I have a device which calls test.php on my application, but I want to route this request to fuelphp.
    for example:

    http://www.example.com/test.php?var1=test&var2=test2 (this is called by my device) >> should route to http://www.example.com/test1?var1=test&var2=test2

    I have a routes.php in my fuelphp, 

    return array(
    'test1'                    => 'api/test1',
    );

    This is my nginx config:

    location = /test.php
    {
       try_files $uri $uri/ /index.php?/test1$is_args$args;
    }

    location ~ ^/index.php$
    {
       include /etc/nginx/custom/php.conf;

       fastcgi_param FUEL_ENV production;
       fastcgi_pass php;
    }

    but when I dump my $_GET array is see that the first element is not correct:

    [test1?var1] => test
    [var2] => test2

    So how do I fix the try_files so it doesn't screw up my $_GET variables...
  • got it.... REQUEST_URI had test.php in it...

    fixed it this way:

    location = /test.php
    {
       set $request_url /test1$is_args$args;
       try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ ^/index.php$
    {
       include /etc/nginx/custom/php.conf;
       fastcgi_param REQUEST_URI $request_url;
       fastcgi_param FUEL_ENV production;
       fastcgi_pass php;
    }

Howdy, Stranger!

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

In this Discussion