Redirects occur when using index directives

Asked 2 years ago, Updated 2 years ago, 47 views

Configuring Nginx to map URL paths to static files.

After accessing http://www.test.com/foo/,
http://www.test.com/foo.php is the image on which the runs.

The configuration is done using locaion {index..}.
In the example above, the settings are as follows.

 location/foo{
   index foo.php
}

The specification states that the index directive is internally redirected to the specified file.However, it has actually been externally redirected (301 Moved Permanent) and has returned to the browser before sending requests to the server again.

Therefore, when a request is thrown at POST, the index directive externally redirects the browser to which it is redirected (most browser specifications) by GET, so the server can only see it in GET, and the POST parameters are missing.

http://www.test.com/foo/ and run http://www.test.com/foo.php.
If possible, it does not have to be in location{index} format.
Anyway, I want to stop being redirected to my browser at 301 (302, 303, 307).

nginx

2022-09-30 18:14

1 Answers

I think you should use rewrite.

 location/foo{
    rewrite/foo/foo.php;
}


2022-09-30 18:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.