Question

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

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;
        }
    }

}

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi,

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.