Hello. There is a site in whose location I want to make a rewrite to another page in case the link ends in .php
For example, if we want to do so http://www.site.com/new-inventory/getfile.php
then we will have to go to http://www.site.com/this-new-rewrited-page
Did so, but it does not work.
location /new-inventory { rewrite .*\.php /this-new-rewrited-page; }
So did too:
location ~ /new-inventory/.*\.php { rewrite .* /this-new-rewrited-page; }
Both options do not work, gives 404, as if I request a file that does not exist. Yes, I am requesting a non-existent file, but a check on whether the file exists and an error should not be performed BEFORE operations in the locale are executed. Tell me what I'm doing wrong?
location / { rewrite /new-inventory/.*\.php /this-new-rewrited-page last; rewrite ^(.*)$ /index.php last; }
My Location. He wrote it in it.
location / {...}
goes. Actually, the last and fulfills it. Those. it is necessary to write checks already inside thislocation
. You can catch earlierlocation = /this-new-rewrited-page {...}
- specify the exact match. In general, too little information. Just now, I was pulling information from one friend to solve his problem . - romeo/
location. - Mihail Politaevrewrite /new-inventory/.* /this-new-rewrited-page last;
it works. It is worth adding at the end\.php
- no. As if nginx understands that this is a file and immediately tries to find it in this location. We need to give him to understand that he did not try to find this file. - Mihail Politaev