LoginSignup
0
0

More than 5 years have passed since last update.

IIS5・PHP5で該当ページの「http」から「https」にURLを飛ばしたい。

Last updated at Posted at 2018-10-31

やりたい事

・「http://xxx.login.php」から「https://xxx.login.php」に飛ばしたい。
・上記ページのみSSLでhttp;//xxxはそのままにしておきたい。

環境

IIS 5.2
PHP Version 5.2.5
Windows server 2003 R2

最初に試した事(※こちらでは問題は解決しませんでした)

IISマネージャーから該当ページのプロパティから下記のように設定。

iis設定.png

参考:http://www.atmarkit.co.jp/ait/articles/0908/07/news108.html

しかし、Google Chrome・IE以外のブラウザではリダイレクトされませんでした。

PHPで解決

login.phpにリダイレクト処理を入れたlogin_ssl.phpをincludeしました。

login.php
<?php
  include_once('./login_ssl.php');
  ///
?>
login_ssl.php
<?php
/*
http ⇒ httpsにリダイレクト
*/
if (!(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
    Header( "HTTP/1.1 301 Moved Permanently" ); 
    Header( "Location: https://xxx/login.php" );
}
?>

これで無事どのブラウザでもhttpsに飛ぶようになりました。

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