使用 web.config 将 IIS 重定向到 PHP

发布于 2024-11-19 14:40:09 字数 2077 浏览 3 评论 0原文

我写了这个文件用于重定向,但我不明白为什么第六个重定向不起作用。所有其他的都可以工作。

我对 IIS 和 ASP 确实很陌生(并且打算保持这样:)),但需要对此进行一些澄清,以便我可以继续。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="r1">
                    <match url="contact.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/contact/"/>
                </rule>
                <rule name="r2">
                    <match url="send2friend.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/contact/"/>
                </rule>
                <rule name="r3">
                    <match url="admin/login.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/wp-admin/"/>
                </rule>
                <rule name="r4">
                    <match url="members-club/join_member.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/newsletter/"/>
                </rule>
                <rule name="r5">
                    <match url="articles/dynamic-web-archive.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/blog/articles-and-newsposts/"/>
                </rule>
                <rule name="r6">
                    <match url="articles/dynamic-web-articles.aspx?page_id=55&amp;parent_id=0&amp;pgnm=%D7%97%D7%92%D7%99%D7%9D"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/blog/%D7%93%D7%99%D7%90%D7%98%D7%94-%D7%91%D7%97%D7%92%D7%99%D7%9D/"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I've wrote this file for redirection and I don't understand why the sixth redirection does not work. all the other ones do work.

I'm really new to IIS and ASP (and intend to keep myself like this :) ) but need some clarification about this so I could move on.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="r1">
                    <match url="contact.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/contact/"/>
                </rule>
                <rule name="r2">
                    <match url="send2friend.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/contact/"/>
                </rule>
                <rule name="r3">
                    <match url="admin/login.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/wp-admin/"/>
                </rule>
                <rule name="r4">
                    <match url="members-club/join_member.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/newsletter/"/>
                </rule>
                <rule name="r5">
                    <match url="articles/dynamic-web-archive.aspx"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/blog/articles-and-newsposts/"/>
                </rule>
                <rule name="r6">
                    <match url="articles/dynamic-web-articles.aspx?page_id=55&parent_id=0&pgnm=%D7%97%D7%92%D7%99%D7%9D"/>
                    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/blog/%D7%93%D7%99%D7%90%D7%98%D7%94-%D7%91%D7%97%D7%92%D7%99%D7%9D/"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

友谊不毕业 2024-11-26 14:40:10

您的最后一条规则 (r6) 无效。 URL 模式不能包含查询字符串。查询字符串必须通过条件单独匹配。

这是正确的规则:

<rule name="r6" stopProcessing="true">
    <match url="^articles/dynamic-web-articles\.aspx$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="page_id=55&parent_id=0&pgnm=%D7%97%D7%92%D7%99%D7%9D" />
    </conditions>
    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/blog/%D7%93%D7%99%D7%90%D7%98%D7%94-%D7%91%D7%97%D7%92%D7%99%D7%9D/" />
</rule>

Your last rule (r6) is invalid. The URL pattern CANNOT include query string. Query String has to be matched separately, via conditions.

Here is correct rule:

<rule name="r6" stopProcessing="true">
    <match url="^articles/dynamic-web-articles\.aspx$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="page_id=55&parent_id=0&pgnm=%D7%97%D7%92%D7%99%D7%9D" />
    </conditions>
    <action type="Redirect" redirectType="Permanent" url="http://www.doctornestor.co.il/blog/%D7%93%D7%99%D7%90%D7%98%D7%94-%D7%91%D7%97%D7%92%D7%99%D7%9D/" />
</rule>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文