Secure storage of database credentials

后端 未结 3 358
闹比i
闹比i 2021-01-03 07:53

Had a major problem recently where my web hosting company messed up and all my php files were displayed in plain text. This was a major issue for me for obvious reasons. Mai

3条回答
  •  庸人自扰
    2021-01-03 08:20

    Simply place info.php outside your webroot. This way, you can include it, but should your web hosting f*#$ up, no one else can view that file, even as plain text.

    You would then include it like this:

    include('../info.php');

    This way, even if someone finds out that you have a file called info.php that stores all your passwords, they cannot point their browser to that file.

    The above would be the ideal and most watertight solution. However, if that is not possible due to permissions, the other option would be to place all sensitive files in a directory and block direct access to that directory using a .htaccess file.

    In the directory you want to block off access to, place an .htaccess file with the following contents:

    deny from all

提交回复
热议问题