コンテンツにスキップ

ドメインを別のドメインにリダイレクトする

エイリアスドメインが他のドメインにトラフィックを転送するだけの場合、Cloudflare内で直接リダイレクトを設定できます。

  1. Cloudflareにドメインを追加します(例: previous.com)。

  2. エイリアスドメインがDNSクエリを正しく解決するプロキシされた DNS AまたはCNAMEレコードを持っていることを確認してください。また、wwwサブドメインのレコードも含めることをお勧めします。

    タイプ名前IPv4アドレスプロキシステータス
    A@192.0.2.1プロキシ
    Awww192.0.2.1プロキシ
  3. リダイレクトルールを使用して、エイリアスドメインから他のドメインにトラフィックを転送します。

    This example single redirect will redirect all requests for smallshop.example.com to a different hostname using HTTPS, keeping the original path and query string.

    When incoming requests match

    • Field: Hostname
    • Operator: equals
    • Value: smallshop.example.com

    If you are using the Expression Editor, enter the following expression:
    (http.host eq "smallshop.example.com")

    Then

    • Type: Dynamic
    • Expression: concat("https://globalstore.example.net", http.request.uri.path)
    • Status code: 301
    • Preserve query string: Enabled

    For example, the redirect rule would perform the following redirects:

    Request URLTarget URLStatus code
    http://smallshop.example.com/https://globalstore.example.net/301
    http://smallshop.example.com/admin/?logged_out=truehttps://globalstore.example.net/admin/?logged_out=true301
    https://smallshop.example.com/?all_items=1https://globalstore.example.net/?all_items=1301
    http://example.com/about/(unchanged)n/a