Slimを使用してこれらの画像を返すことを検討してください。あなたの手でコントロールが保持されます。いつでもあなたのルートやフォルダを変更することができます。また、追加のヘッダーを設定することもできます。キャッシングのために。
assets/images/client.png
ような場合のURLは
$app->get('/assets/images/{pathToClientImage}', function($request, $response, $args) {
$pathToFile = $args['pathToClientImage'];
$containingFolder = '../clients_images/'; // the actual folder where files are stored
// since you want to omit file extension in the url, we'll have to find the file
$matches = glob($containingFolder.$fileName.'.*');
if ($matches) {
$clientImagePath = array_shift($matches); // let's grab the first file matching our mask
$clientImage = @file_get_contents($clientImagePath);
$finfo = new \Finfo(FILEINFO_MIME_TYPE);
$response->write($clientImage);
return $response->withHeader('Content-Type', $finfo->buffer($clientImage));
} else {
// if no matches found, throw exception that will be handled by Slim
throw new \Slim\Exception\NotFoundException($request, $response);
}
});
(ファイル拡張子を持つ)を使用すると、簡単な方法でこれを行うことができ、あなたのための許容可能である:
$app->get('/assets/images/{pathToClientImage}', function($request, $response, $args) {
$pathToFile = $args['pathToClientImage'];
$path = '../clients_images/'.$fileName;
$image = @file_get_contents($path);
$finfo = new \Finfo(FILEINFO_MIME_TYPE);
$response->write($image);
return $response->withHeader('Content-Type', $finfo->buffer($image));
});
あなたとあなたの '.htaccess'ファイルにこれを追加する必要があります既定の構成フォルダの要求はindex.phpに送信されます – jmattheis