LoginSignup
1
1

More than 5 years have passed since last update.

h2oのリダイレクト設定が簡単すぎる件

Posted at

一行でリダイレクト実装

先日h2oのベーシック認証を実装した際、めちゃくちゃ大変だったのですが、常時SSL通信させるためのリダイレクト設定は鬼のように簡単でした。

これがApacheだと、あちこちのコンフィグを弄り回さないとならないですが、h2oはなんと一行!!一行ですよ!? さすがにビビりました

/etc/h2o/sites-enabled/mydomain.conf
~省略~
hosts:
 "mydomain:80":
   listen:
     port: 80
   paths:
     "/":
      redirect: https://mydomain #この行を追記する
      file.dir: /var/www/html

あとは、WordPressを使っているので、wp-config.phpにあるサイトURLも変更してあげるだけです。

/var/www/html/wp/wp-config.php
define( 'WP_SITEURL', 'https://mydomain' );
define( 'WP_HOME', 'https://mydomain' );

こ、これだけ。。。
もちろんサーバ証明書を事前に取得する必要がありますが、記述内容はこれだけなのはすごい。
これだけでもh2oを使う価値があるレベル。
もちろん速度的な意味でApacheの比じゃないですが、やってて面白いのはこっちかな?

1
1
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
1
1