Last-modified: 2011-12-26 (月) 01:24:44
PHP/HTTPレスポンスヘッダからPHPのバージョン表記を削除したい

概要

HTTPレスポンスヘッダに含まれるPHPのバージョン情報を削除してみます。

手順

  1. <php.ini>を開きます。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
    
    -
    |
    |
    !
    -
    |
    |
    |
    |
    |
    !
    
    ;;;;;;;;;;;;;;;;;
    ; Miscellaneous ;
    ;;;;;;;;;;;;;;;;;
     
    ; Decides whether PHP may expose the fact that it is installed on the server
    ; (e.g. by adding its signature to the Web server header).  It is no security
    ; threat in any way, but it makes it possible to determine whether you use PHP
    ; on your server or not.
    ; http://php.net/expose-php
    ; この値をOffにすると、HTTPレスポンスヘッダのX-Powered-ByにPHPのバージョンが載りません
    expose_php = Off
  2. Apacheを再起動します。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    /etc/init.d/httpd restart
  3. HTTPレスポンスヘッダを確認します。
    今回はlynxで確認しました。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
    
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
    lynx -head -dump <URL>
     
    HTTP/1.1 200 OK
    Date: Wed, 08 Dec 2010 15:14:47 GMT
    Server: Apache
    Accept-Ranges: bytes
    Cache-control: no-cache
    Pragma: no-cache
    Content-Type: text/html; charset=UTF-8
    X-Pad: avoid browser bug
    Vary: Accept-Encoding
    Connection: close
     
    [X-Powered-By:]欄がなければ成功です。

検証時の環境