I am trying to implement multiple redirection rules according to particular conditions in web config file on IIS server. I am new to web config file, current web config file is already setup on server. I need to implement one more rule to it. I searched on google but unable to get it work as i have lack of knowledge for web config. Let me explain what i am looking here:
We have a directory "read" on server which contains further some child directories which are having their independent index.html file with css/images. Whenever user hit the url of any sub-directory in "read" directory, i need to track some information via PHP script. So, I have made a PHP script which will filter the url and track their entry then redirect back to the same url which was opened by user. I have placed the php file in "read" folder. Now i am trying to create rule which will first hit php script file before opening any sub-directory content. Anyone please help?
Eg. user will hit:- "https://www.example.com/read/first/index.html"
PHP file url:- "https://www.example.com/read/index.php"
Parent directory is "read". I have following rules already present in web config file:-
<rewrite>
<rules>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="WordPress Rule 2" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
<action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
</rule>
<rule name="WordPress Rule 3" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
<action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
</rule>
<rule name="WordPress Rule 4" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
<add input="{URL}" pattern="([a-zA-Z0-9\./_-]+)\.axd" />
</conditions>
<action type="None" />
</rule>
<rule name="WordPress Rule 5" stopProcessing="true">
<match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="WordPress Rule 6" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
<action type="Rewrite" url="{R:2}" />
</rule>
<rule name="WordPress Rule 7" stopProcessing="true">
<match url="." ignoreCase="false" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>