So, I want to implement a url:example.com/test.php/a/b/c, the Web directory has a test.php file, want to receive/a/b/c as routing parameters to implement the routing function.
If you do not set the Rewite rule, it is possible to open example.com/test.php, but open example.com/test.php/a/b/c will report 404. And then I just want to rewrite the rules myself.
After trying a lot of times, I found
location /test.php { rewrite . /test.php last; }
This will make the page normal access, and PHP $_server[' Request_uri '] is test.php/a/b/c, to meet my needs. But it's not right to change last to break.
I would like to know why the last can be successful rewrite, has the URL rewrite to/test.php, why the/a/b/c/can still be retained? And why not use a break.
And last this flag, will not stop the location of the match Ah, test.php was rewrite to test.php should still enter this location and infinite loop return 500 is. Why does this work?
Although I have achieved the function I want, but I really do not know what the reason for this.
Reply content:
So, I want to implement a url:example.com/test.php/a/b/c, the Web directory has a test.php file, want to receive/a/b/c as routing parameters to implement the routing function.
If you do not set the Rewite rule, it is possible to open example.com/test.php, but open example.com/test.php/a/b/c will report 404. And then I just want to rewrite the rules myself.
After trying a lot of times, I found
location /test.php { rewrite . /test.php last; }
This will make the page normal access, and PHP $_server[' Request_uri '] is test.php/a/b/c, to meet my needs. But it's not right to change last to break.
I would like to know why the last can be successful rewrite, has the URL rewrite to/test.php, why the/a/b/c/can still be retained? And why not use a break.
And last this flag, will not stop the location of the match Ah, test.php was rewrite to test.php should still enter this location and infinite loop return 500 is. Why does this work?
Although I have achieved the function I want, but I really do not know what the reason for this.
Last after the rule is matched, it jumps to the rule and goes inside.
Break does not match to the rule.
That's the difference between the two.