LoginSignup
6
3

More than 5 years have passed since last update.

nginx で転送設定をする方法

Posted at

設定方法

/etc/nginx/nginx.confファイルにリダイレクトルールを書き込む。

SSLの場合は/etc/nginx/conf.d/default-ssl.confファイルに設定を書き込む。

テンプレート

server {
    # いろいろ記述がある
    # 〜〜〜〜

    # このあたりに書き込む
    location ルール {
        return 301 転送先;
    }
}

具体例

具体的には次のような例となります。http://example.com/hoge/http://example.com/hoge/index.htmlの2つのURLが存在するとFacebookやはてなブックマークの数値が分散するので転送設定をかけておくと吉。

server {
    # いろいろ記述がある
    # 〜〜〜〜

    # このあたりに書き込む
    location = /hoge/ {
        return 301 /hoge/index.html;
    }
}

これだとindex.htmlファイルのほうに転送され幸せになる。

6
3
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
6
3