【问题标题】:web.config :: redirect all except root/index.html (Azure, WordPress)web.config :: 重定向除 root/index.html 之外的所有内容(Azure、WordPress)
【发布时间】:2017-02-18 18:27:05
【问题描述】:

我有一个托管在 azure 上的 Wordpress,我已经从 www.mydomain.com 移动到 old.mydomain.com,

在 www.mydomain.com 上,我创建了一个新的登录页面,告知我想要告知的内容并提供指向“旧”wordpress 的链接,

为了避免丢失 seo(并使 wp 信息保持活跃),我制作了下一个 web.config

<?xml version="1.0"?>
  <configuration>
    <system.webServer>
      <httpRedirect enabled="true" destination="http://old.mydomain.com" httpResponseStatus="Permanent" /> 
    </system.webServer>

    <location path="www.mydomain.com">
       <system.webServer>
            <httpRedirect enabled="false" />
        </system.webServer>
    </location>

</configuration>

重定向完美,但它也将我 www.mydomain.com 重定向到 old.mydomain.com

如何在 web.config 这个 no-redirect-the-root 中做到这一点??

我也试过了:

<location path="index.html">
    <system.webServer>
        <httpRedirect enabled="false" />
    </system.webServer>
</location>

但结果是一样的,一切都被重定向到 old.mydomain.com

【问题讨论】:

  • 抱歉打扰了,好像没有人知道这是否可行?

标签: wordpress azure redirect iis azure-web-app-service


【解决方案1】:

您可以尝试使用IIS的Rewrite module,请考虑如下配置:

<configuration>
    <system.webServer>
    <rewrite>
          <rules>
            <rule name="Root rule" stopProcessing="true">
                <match url="^$" />
                <action type="None" />
            </rule>
            <rule name="redirect rule" stopProcessing="true">
                <match url="^(.*)$" />
                <action type="Redirect" url="http://www.example.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
            </rule>
          </rules>
        </rewrite>
        </system.webServer>
</configuration>

【讨论】:

  • 非常感谢!!您的帮助是隧道中的一盏灯 ;-)
猜你喜欢
  • 2014-10-26
  • 2012-05-28
  • 2012-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-01
  • 1970-01-01
相关资源
最近更新 更多