【问题标题】:301 Redirect with separate redirect file (on azure)使用单独的重定向文件进行 301 重定向(在 azure 上)
【发布时间】:2016-10-17 15:42:22
【问题描述】:

我正在尝试使用 Url Rewrite 将旧站点 url 重定向到新站点,并将 url 放在单独的文件中。理想情况下,我希望捕获所有 http 和 https 请求。这就是我的 web.config 中的内容。

<rewrite>
<rewriteMaps configSource="rewritemaps.config" />
    <rules>
        <rule name="Redirect oldsite.com to newsite.com" stopProcessing="true">
        <match url=".*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^www.oldsite.com$" />
            </conditions>
            <action type="Redirect" url="https://www.newsite.com" redirectType="Permanent" appendQueryString="false" />
        </rule>
  </rules>
</rewrite>

在我的 rewritemaps.config 文件中

<rewriteMaps>
<rewriteMap name="Redirects">
  <add key="/~woodburningstove/index.php/contacts/" value="/ContactUs" />
  <add key="/about-us" value="/about-us-2" />
  <add key="/blog" value="/blog" />
  <add key="/brands" value="/manufacturer/all" />
  <add key="/brands/herald" value="/herald-stoves" />
  <add key="/brands/stovax" value="/stovax-stoves" />
  <add key="/brands/town-country" value="/town-country-fires"/>
  <add key="/brands/warmglow" value="/warmglow-stoves"/>
  <add key="/brands/warmglow/warmglow-4-cast-iron-stove-flat-black-paint-finish" value="/warmglow-4-black-2"/>
  <add key="/brands/warmglow/warmglow-7-cast-iron-stove-flat-black-paint-finish" value="/warmglow-7-cast-iron-black"/>
  <add key="/brands/warmglow/warmglow-7-cast-iron-stove-flat-ivory-enamel" value="/warmglow-7-cast-iron-ivory-enamel"/>
  <add key="/brands/warmglow/warmglow-7-cast-iron-stove-flat-metallic-black-enamel" value="/warmglow-7-cast-iron-metallic-black-enamel"/>
  <add key="/brands/warmglow/warmglow-7-cast-iron-stove-flat-metallic-black-enamel" value="/warmglow-7-cast-iron-metallic-black-enamel"/>
</rewriteMap>
</rewriteMaps>

但是我不断收到“页面无法显示,因为发生了内部服务器错误”,但我无法发现我做错了什么!?

【问题讨论】:

    标签: azure redirect iis web-config


    【解决方案1】:

    原因是我的 rewritemaps.config 文件中有重复的条目。以下列出了两次:

    <add key="/brands/warmglow/warmglow-7-cast-iron-stove-flat-metallic-black-enamel" value="/warmglow-7-cast-iron-metallic-black-enamel"/>
    <add key="/brands/warmglow/warmglow-7-cast-iron-stove-flat-metallic-black-enamel" value="/warmglow-7-cast-iron-metallic-black-enamel"/>
    

    【讨论】:

      【解决方案2】:

      是因为你的正则表达式吗?

      旧:

      <add input="{HTTP_HOST}" pattern="^www.oldsite.com$" />
      

      新:

      <add input="{HTTP_HOST}" pattern="^www\.oldsite\.com$" />
      

      否则,我建议关闭自定义错误或进行一些远程调试。 https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-troubleshoot-visual-studio/

      【讨论】:

        猜你喜欢
        • 2016-07-14
        • 2020-03-28
        • 1970-01-01
        • 2015-10-19
        • 2017-10-03
        • 2014-08-30
        • 2017-04-15
        • 2018-03-09
        • 2015-08-15
        相关资源
        最近更新 更多