【问题标题】:Laravel 5 intervention The requested resource someImage.jpg was not found on this serverLaravel 5 干预在此服务器上未找到请求的资源 someImage.jpg
【发布时间】:2015-05-17 12:12:37
【问题描述】:

我正在学习 Laravel 5,但遇到了问题。

如果我尝试像这样将图像传递给路线

http:://localhost/someImage.jpg

路线是这样的:

Route::get('/{filename}', function($filename){

    $img = Image::make(storage_path($filename))->resize(50, 50);
    return $img->response('jpg');
});

它返回请求的资源 someImage.jpg 在此服务器上找不到。

如果我这样称呼它

http:://localhost/someImage

我的路线是

Route::get('/{filename}', function($filename){

    $img = Image::make(storage_path($filename . ('.jpg')))->resize(50, 50);
    return $img->response('jpg');
});

可以显示图片。

我怎样才能使第一个示例工作?

我不确定,但我认为它试图直接访问图像而不是将其传递给路由,并且我需要更改一些配置以防止它。也许在htaccess中?

.htaccess 内容

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

【问题讨论】:

  • 向我们展示您的.htaccess 文件。

标签: php .htaccess laravel laravel-5


【解决方案1】:

确保它在您的存储目录中可用,因为您使用的是 storage_path() 方法。

【讨论】:

    猜你喜欢
    • 2021-03-07
    • 2019-12-17
    • 2017-05-09
    • 2021-09-10
    • 2018-11-05
    • 2018-05-14
    • 1970-01-01
    • 2015-12-17
    • 2016-12-21
    相关资源
    最近更新 更多