2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

amazonaws.comドメインをリダイレクト(SEO対策)

Last updated at Posted at 2016-05-03

AWSでELBを作成した場合、

ELB名-番号.ap-northeast-1.elb.amazonaws.com

というドメイン名が割り当てられます。

また、EC2にグローバルIPを付与すると、

ec2-IPアドレス.ap-northeast-1.compute.amazonaws.com

というドメイン名が割り当てられます。

サービスを本番運用する場合は、独自ドメインを定義し、上記ドメイン名を使うことはほとんどありませんが、これらのドメインもグローバルに公開されているため、何かのきっかけで検索エンジンに登録されてしまう可能性があります。

上記AWSドメインを検索エンジンに登録されてしまうとカニバリゼーションを起こしてしまうため、それを防止するために、リダイレクト処理を入れておくと安全です。

Apacheの設定例:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # AWS ドメインの場合は example.com に 301 リダイレクト
    RewriteCond %{HTTP_HOST} .*\.amazonaws\.com
    RewriteRule ^/(.*)$ http://example.com/$1 [R=301,L]

Nginxの設定例:

server {
    listen 80;
    server_name ~.*amazonaws.com$;

    # AWSドメインの場合は example.com にリダイレクト
    rewrite ^(.*)$ https://example.com/$1 permanent;
}
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?