繁体   English   中英

IIS 重写条件规则不起作用

[英]IIS Rewrite conditions rule is not working

首先谢谢大家,英语不是我的母语 但是这个问题对我来说非常困难

我需要http://xxxx.show.bis.tw/event_register/index.php?id=image01http://xxxx.show.bis.tw/event_register/image01

如果用户在地址栏输入http://xxxx.show.bis.tw/event_register/image01网站是可以工作的

我认为规则是用户可以输入那些http://xxxx.show.bis.tw/event_register/image01 http://xxxx.show.bis.tw/event_register/index.php?id=image01

1. http://xxxx.show.bis.tw/event_register/index.php?id=image01 Redirect like this http://xxxx.show.bis.tw/event_register/image01 and go to rule2 Rewrite <action type="Rewrite" url="index.php?id={C:1}" />

2. http://xxxx.show.bis.tw/event_register/image01只重写<action type="Rewrite" url="index.php?id={C:1}" />

我的代码是如果文件和目录执行重定向或重写网站会损坏(css/js/image)

我尝试将 rule>1 和 rule>2 写入一个规则,但它不起作用我不知道如何解决它

    <rewrite>
        <rules>
            // 1
            <rule name="025" stopProcessing="true">
                 <match url=".*" />
                 <conditions>    // file and directory not Redirect|Rewrite
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Redirect" url="{C:0}" appendQueryString="false" />
            </rule>
            // 2
            <rule name="026">
                <match url="index\.php(.*)" />
                <conditions>
                    <add input="{QUERY_STRING}" pattern="id=(.*)" />
                </conditions>
                <action type="Redirect" url="{C:1}" appendQueryString="false" />
            </rule>
            // 3
            <rule name="027" enabled="true" stopProcessing="true">
                <match url=".*" ignoreCase="true" />
                <conditions>
                    <add input="{URL}" pattern="/index.php?id=" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php?id={R:1}" />
            </rule>
        </rules>
    </rewrite>

谢谢大家,非常感谢,我几乎两天无法入睡,只需解决这个问题

您是否在 web.config 文件中尝试过重写映射而不是规则?

 <configuration> <system.webServer> <rewrite> <rewriteMaps> <rewriteMap name="rewrites"> <add key="/event_register/image01" value="/event_register/index.php?id=image01" /> </rewriteMap> </rewriteMaps> </rewrite> </system.webServer> </configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM