Unexpected 302 error (Moved Temporarily) after login in my website

September 21, 2015 1.7k views

I have a website running with Nginx and PHP-FPM (www.example.com), however when I try to access www.example.com/user/login to access its administration and put the correct login info, it just reload the login info page apparently, but seeing in Firefox Network console whats happening is a 302 error (Moved Temporarily) when trying to access www.example.com/index.php/panel/index which it must load right before you log into it.

It's driving me crazy because after reading about it, it has to do with redirections, which I have none in my host or nginx configurations.

Please help me.

Here's my vhost configuration:

server {
    listen   80;
    server_name  example.com;

    charset UTF-8;
    access_log  /var/log/nginx/example.access.log  main;
    error_log /var/log/nginx/example.error.log;

    root   /usr/share/nginx/html/example/;
    index index.php index.html index.htm;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html/;

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/example/index.php;

    location / {
        if (!-e $request_filename){
        rewrite ^(.*)$ /index.php;

1 Answer


The issue appears to be with the regex in the

 location / {
        if (!-e $request_filename){
        rewrite ^(.*)$ /index.php;

block - which attempts to redirect traffic, but if the regex is modified to

` rewrite ?(.*)$ /index.php;

this may address it.

Have another answer? Share your knowledge.