カテゴリー︎: 【PHP】
phpのファイル名、がソースコードに出ている場合につかう想定。
例えば、画像のパスをみせたくない場合など
hoge.php
<?php
//hoge.phpへの直リンク禁止
if (empty($_SERVER["HTTP_REFERER"])) {
//任意のページへリダイレクト
header('Location: http://faq.tank.jp/skill/');
}
//画像を読み込む
$my_img = file_get_contents("images/img.png");
header('Content-type: image/png');
echo $my_img;
?>
これで、hoge.phpにアクセスされても
images/img.png のパスはユーザーには分からない。