ON my job I was asked to migrate a php application running on iis/azure into running via nginx and fpm over a GNU+Linux machine.
Then on the process I encountered a file named web.config
containing entries for example:
<action name="SomeName" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions>
<add input="{URL}" pattern="^some_regex^">
</conditions>
<action type="Rewrite" url="index.php?someaction={C:1}">
</action>
Or
<action name="SomeName" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions>
<add input="{URL}" pattern="^some_regex^">
</conditions>
<action type="Rewrite" url="index.php?someaction={R:1}">
</action>
So far I thought that an nginx mapping like that:
^some_regex^ index.php?someaction=$1;
Would do the job in both actions (somehow). But I still cannot understand the difference between {C:1} and {R:1} on regex maches I understand that in my nginx would be something like $1 (a subregex match) but what different to the web.config is {C:1} and {R:1} entries?
I am asking because I may need to change the nginx's subregex matches a bit regarding if the match is {C:1} or {R:1}.
here is your answer
Back-references to condition patterns are identified by {C:N}
where N is from 0 to 9. Back-references to rule patterns are identified by {R:N}
where N is from 0 to 9. Note that for both types of back-references, {R:0}
and {C:0}
, will contain the matched string. For more detailed info you can have a look on: IIS URL Rewrite {R:N} clarification
Further info you can find on: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#using-back-references-in-rewrite-rules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With