1

I remove the .php file attachment in the application, but this time the application's action pages do not work. Because I removed the .php suffix at the end of the files.

For example, I want to send data to a collect file with AJAX but I get 302 returns.

https://panel.example.com/application/collect

There is no problem with other files of the application.

https://panel.example.com/login
*Version without rewrite:*
https://panel.example.com/index.php?cmd=login

How can I fix the 302 redirect issue in the app's working files? Where am I doing wrong?

location / {
try_files $uri $uri/ /index.php?$args;
} 

rewrite ^/([^/]+)/([^/]+)?$ /index.php?cmd=$1&scd=$2 break;
rewrite ^/([^/]+)/?$ /index.php?cmd=$1 break; 

The above code is not included in the full configuration file. I have uploaded the clean file.


CURL by CMD;

C:\Users\emres>curl -I https://panel.example.com/application/collect
HTTP/1.1 302 Found
Server: nginx/1.18.0
Date: Sun, 02 Jan 2022 12:32:57 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: PHPSESSID=pvn7l2g8babucp9a9mkuo5ll0v; path=/; domain=.example.com
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Access-Control-Max-Age: 86400
Access-Control-Allow-Credentials: true
Location: https://panel.example.com/login?returnBack=http://panel.example.com/application/collect

error.log:

clean.

access.log:

192.168.1.145 - - [02/Jan/2022:15:36:22 +0300] "GET /application/collect HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33"
192.168.1.145 - - [02/Jan/2022:15:36:22 +0300] "GET /login?returnBack=https://panel.example.com/application/collect HTTP/1.1" 200 3977 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33"
192.168.1.145 - - [02/Jan/2022:15:36:22 +0300] "GET /libs/out/general-js.php?v=61d19c464ab3b HTTP/1.1" 200 390 "https://panel.example.com/login?returnBack=https://panel.example.com/application/collect" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33"
192.168.1.145 - - [02/Jan/2022:15:36:22 +0300] "POST /application/collect HTTP/1.1" 302 5 "https://panel.example.com/login?returnBack=https://panel.example.com/application/collect" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33"
192.168.1.145 - - [02/Jan/2022:15:36:22 +0300] "GET /login?returnBackUnit=https://panel.example.com/application/collect HTTP/1.1" 200 3981 "https://panel.example.com/login?returnBack=https://panel.example.com/application/collect" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33"

Nginx: 1.18

I think it detects "application/collect" path differently. It detects it as application for cmd and collect for scd for index.php Because I can access this page: https://panel.example.com/application/microServices/web - but, https://panel.example.com/application/collect not possible to access. I think it's affecting the rewrite.

Emre6
  • 151
  • 2
  • You are redirected to login page by a 302. You may check how pass the authentication to be directely sent to the right page – Dom Jan 02 '22 at 15:16

0 Answers0