dimanche 29 janvier 2017

How to configure nginx rewrite rules for fuelphp framework?

Ive faced this problem when trying to execute an action from a controller in fuelphp framework, I get an 404 message from nginx. Im able to see, for e.g. localhost/index.php or just localhost, but when I try to access to an action-controller like localhost/http://ift.tt/2jtEWQn I get the 404 error. Can anyone help me? this app is currently working in apache, I was facing this trouble here too but everything got fine when I executed

a2enmod rewrite

then I tried to search for equivalent config for nginx and I found this like:

location /{ try_files $uri $uri/ /index.php?$args /index.php?q=$request_uri }

or this:

location /{
rewrite ^ /index.php?/$request_uri;}

but they didnt work for me. Ive spent several hours trying to find out the reason. This is my actual vhost file config for my site:

server {
        listen 80;
        listen [::]:80;
        root /var/www/nginx/goutmeet;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name goutmeet.local www.goutmeet.local;

        location / {
        try_files $uri $uri/ /index.php?$args  /index.php?q=$request_uri @handler;
        }
 location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
location @handler {
                rewrite ^ /index.php?/$request_uri;
        }
}

Id love to know how to solve this since using nginx sometimes is a better option than apache, and having this issue with fuelphp framework and not being able to use this two great tools together is awful. Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire