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

  • Posted September 21, 2015
  • Nginx

I have a website running with Nginx and PHP-FPM (, however when I try to access 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 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;

    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
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.


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.