I know and can successfully redirect through rewrite.
But I learned from Brother Niao’s blog that besides rewrite, is there another way to pass settings?
Brother Niao nginx pathinfo portal
Brother Niao mentioned in the blog what is the principle behind the methods other than rewrite redirection?
I know and can successfully redirect through rewrite.
But I learned from Brother Niao’s blog that besides rewrite, is there another way to pass settings?
Brother Niao nginx pathinfo portal
Brother Niao mentioned in the blog what is the principle behind the methods other than rewrite redirection?
This article by Brother Bird is actually a bit confusing in concept.
First of all, the Rewrite redirection method mentioned by Brother Niao refers to passing PATH_INFO to PHP through Nginx redirection through Query String.
For example, we request /user/1
through the redirect rule, and change it to /index.php?path_info=/user/1
.
This method requires the PHP script to collect Query String to analyze PATH_INFO, and certain compatibility adaptations are required.
The second method introduced by Brother Niao is to let PHP disassemble the PATH_INFO information.
For example, if we request /index.php/user/1
, PHP can automatically disassemble the path after the script as PATH_INFO, which is /user/1
.
Brother Niao said that since certain security issues may arise when PHP is disassembled, this method is still not recommended.
Finally, Brother Niao introduced another method. Generally speaking, it is the method of disassembling /user/1
from /index.php/user/1
, but this time the disassembly process is done by Nginx Completed, this method is completed on Nginx that receives the request. Compared with the first two methods of completing disassembly in PHP, this method is more effective because more information can be used and more directly.
But, But, generally speaking, we do not display the URL in the form of /index.php/user/1
, but we hope to hide the entrance of the program, which is displayed as /user/1
. Therefore, in this process, we still need to use Nginx's Rewrite to complete the process of hiding the program entry and redirecting to the program entry script. The hidden entry configuration of PHP+Nginx usually seen on the Internet is completed by Rewrite in conjunction with the last method of dismantling PATH_INFO.
So there are certain problems with Brother Niao’s proposal. The first method of disassembling PATH_INFO cannot be simply equated with Nginx’s Rewrite.