【问题标题】:Redirecting a subdomain to subfolder in azure web app将子域重定向到 azure Web 应用程序中的子文件夹
【发布时间】:2019-03-07 12:18:48
【问题描述】:

我想将子域重写为 azure webapps 中的子文件夹

我有这个子域:https://portal.domain.com.br(在单独的服务器上运行)。我想使用这个网址:domain.com.br/portal

这是我的 web.config:

 <rewrite>
  <rules>
   <rule name="Rewrite to portal site" stopProcessing="true">
    <match url="^portal\/([_0-9a-z-/]+)" ignoreCase="true" />
    <action type="Rewrite" url="https://portal.domain.com.br/{R:1}" appendQueryString="true"/>
    </rule>
  </rules>
</rewrite>  

我也试过这个:

    <rewrite>
  <rules>
   <rule name="Rewrite to portal site" stopProcessing="true">
    <match url="^portal$" />
    <action type="Rewrite" url="https://portal.domain.com.br/{R:0}" />
    </rule>
  </rules>
</rewrite>   

这些都不起作用。如何进行?

【问题讨论】:

  • 我也面临同样的问题。如果你知道它是如何工作的,你能指导我吗?

标签: asp.net azure url-rewriting web-config azure-web-app-service


【解决方案1】:

确保您在 DNS 中为该子域添加了 CNAME。然后使用重写规则将请求从abc.example.com 重定向到http://example.com/abc

这是一个例子:

  <rewrite>
    <rules>
      <rule name="CName to URL" stopProcessing="true">
        <match url=".*" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.example\.com$" />
        </conditions>
        <action type="Redirect" url="http://example.com/{C:1}/{R:0}" />
      </rule>
    </rules>
  </rewrite>

请参阅this

【讨论】:

  • 我只想对这个子域进行重写,而不是对所有人
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-10
  • 2014-09-05
  • 2012-11-23
  • 1970-01-01
  • 1970-01-01
  • 2016-01-15
  • 1970-01-01
相关资源
最近更新 更多