LoginSignup
9
11

More than 5 years have passed since last update.

FuelPHPでHTTPS通信へリダイレクトする方法

Posted at

FuelPHPでHTTP通信が来た場合にHTTPS通信へリダイレクトする方法

rest.php
public function before() {
    // HTTP通信ならリダイレクトする
    if (!strstr(Input::protocol(), 'https')) {
        $url = 'https://' . Input::server('HTTP_HOST') .  Input::server('REQUEST_URI');
        Response::redirect($url, 'location', 301);
        die;
    }
    return parent::before();
}

die; が要るのかは謎です。

参考サイト
FuelPHP method-specific, controller-based SSL solution
FuelPHP1.6、Inputクラスの中身を理解する。

9
11
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
9
11