dousha7645 2019-03-18 09:37
浏览 318

IIS服务器上的Web配置文件中出现多个重定向规则问题

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作