<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">I am trying to migrate to <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">Nginx + PHP-FPM</code> from <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">Apache + mod_php</code>. I am currently using <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">mod_rewrite</code> to rewrite some virtual URIs ending in <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">.php</code> to actual PHP scripts. This works perfectly when using <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">mod_php</code>. But with with <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">Nginx + FPM</code>, since we have to use <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">proxy_pass</code>, this is not working. When I add a regex location block to match <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">.php</code> extension, it gets higher precedence, and my rewrite rules are not applied.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">How can I resolve this?</p><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">location </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">/</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">test</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">/</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
rewrite </span><span style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">"^/test/([a-z]+).php$"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> test</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">php</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">?</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">q</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">$1 </span><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">last</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">}</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
location </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">~</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">[^</span><span style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">/]\.php(/</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">|</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">$</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
fastcgi_split_path_info </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">^(.+?</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">\.php</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)(/.*)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">$</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">set</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> $fastcgi_script_name_custom $fastcgi_script_name</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">if</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(!-</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">f $document_root$fastcgi_script_name</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">set</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> $fastcgi_script_name_custom </span><span style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">"/cms/index.php"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">}</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
fastcgi_pass </span><span style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">127.0</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">0.1</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">9000</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
fastcgi_index index</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">php</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
include fastcgi_params</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">}</span></code></pre><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Thank,</font></div><div style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Joyce Babu</font></div><div style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:12.8px"><font face="arial, helvetica, sans-serif">NB: This is a sample configuration. There are several such rewrite rules, hence I cannot use a exact match or regular expression location block to override the php proxy location block.</font></div></div>