LoginSignup
3
2

More than 5 years have passed since last update.

web.configを使って、別ドメインへリダイレクトさせる方法

Posted at

やりたいこと

開発中のテストアドレスを本番アドレスへリダイレクトさせる。
web.configを使うと結構簡単にできます。
正規表現でマッチさせるので、汎用性も高いですね。

web.config
<?xml version="1.0"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="sevengods-web" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^7test-web\.trafficmanager\.net$" />
          </conditions>
          <action type="Redirect" url="https://www.production-web.jp/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2