You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure中如何将https://myfirstdomain.com/register重定向至目标域名?

解决方案:实现特定路径的永久重定向

一、Azure Functions Proxies临时启用方案

若需临时恢复Proxies功能,可直接在Function App根目录添加proxies.json文件,无需依赖门户操作,示例配置如下:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "RegisterRedirectProxy": {
      "matchCondition": {
        "route": "/register"
      },
      "responseOverrides": {
        "response.statusCode": "301",
        "response.headers.Location": "https://myseconddomain.com"
      }
    }
  }
}

注意:该功能2025年将正式弃用,仅建议作为短期过渡方案。

二、Azure API Management(APIM)实现重定向步骤

  1. 创建API并配置路由:在APIM实例中新建API,将路由模板设置为/register,后端服务可指向原Azure Function(或直接跳过后端配置,仅用重定向策略)。
  2. 添加入站重定向策略:在该API的入站策略中插入以下XML配置,实现301永久重定向:
<inbound>
    <base />
    <return-response>
        <set-status code="301" reason="Moved Permanently" />
        <set-header name="Location" exists-action="override">
            <value>https://myseconddomain.com</value>
        </set-header>
    </return-response>
</inbound>
  1. 绑定旧域名:将myfirstdomain.com绑定到APIM实例,确保该域名下的/register请求全部经过APIM处理。

三、低成本简便方案:DNS+目标站点配置

如果旧域名仅需处理/register路径的重定向,可采用以下两步实现:

  1. DNS解析配置:将myfirstdomain.com的CNAME记录指向myseconddomain.com,同时确保目标App Service已添加该旧域名的自定义域名绑定。
  2. 目标站点重定向规则:
    • 若目标是.NET App Service,在web.config中添加重写规则:
    <rewrite>
      <rules>
        <rule name="RegisterRedirect" stopProcessing="true">
          <match url="^register$" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^myfirstdomain.com$" />
          </conditions>
          <action type="Redirect" url="https://myseconddomain.com" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    
    • 若目标是Linux App Service,修改nginx.conf添加规则:
    server {
      listen 80;
      server_name myfirstdomain.com;
      location = /register {
        return 301 https://myseconddomain.com;
      }
    }
    

内容的提问来源于stack exchange,提问作者Fabian Bigler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 00:25:05