Laravel Glide在带有扩展名的URL上找不到图像
我用的是Glide,然后看了这段视频,基本上是一段走查 查看官方网站上的说明 这是我的服务提供商:Laravel Glide在带有扩展名的URL上找不到图像,laravel,image-manipulation,php-glide,Laravel,Image Manipulation,Php Glide,我用的是Glide,然后看了这段视频,基本上是一段走查 查看官方网站上的说明 这是我的服务提供商: $this->app->singleton('League\Glide\Server', function ($app) { return \League\Glide\ServerFactory::create([ 'source' => public_path(), 'cache' => p
$this->app->singleton('League\Glide\Server', function ($app) {
return \League\Glide\ServerFactory::create([
'source' => public_path(),
'cache' => public_path(),
'source_path_prefix' => 'images/uploads',
'cache_path_prefix' => 'images/cache',
'base_url' => '/img/',
]);
});
以下是我目前的路线:
Route::get('img/{path}', function (League\Glide\Server $server, Illuminate\Http\Request $request) {
$server->outputImage($request);
});
但是我遇到了问题。当我转到url.com/img/test.png?h=100时,它不起作用。当看铬的时候
开发工具在页面上,我得到一个404的图像(然而,原始图像确实出现)
我发现,如果我将路线切换到以下位置,并且只转到url.com/img/test?h=100(不带扩展名),
然后我得到我想要的滑动图像:
Route::get('img/{path}', function (League\Glide\Server $server, Illuminate\Http\Request $request) {
$server->outputImage($request->path() . '.png', $request->all());
});
但是,如果我删除扩展的连接并简单地使用:
Route::get('img/{path}', function (League\Glide\Server $server, Illuminate\Http\Request $request) {
$server->outputImage($request->path(), $request->all());
});
然后路由回url.com/img/test.png?h=100,再次失败
你觉得我做的有什么不对吗,或者有没有解释为什么我不能直接进入图片
路径(带扩展名)?这都是缓存问题。在使用Glide之前,不要通过htaccess或nginx缓存图像。我也有同样的问题,并尝试了很多方法。所有以/img/开头的url都是Glide生成的图像。/assets/中的所有文件都是静态文件。 我放弃了,改变了
location~*\(?:jpg | jpeg | gif | png | ico | cur | gz | svg | svgz | mp4 | ogg | ogv | webm | htc)$
到
location~*^/assets/*\(?:jpg | jpeg | gif | png | ico | cur | gz | svg | svgz | mp4 | ogg | ogv | webm | htc)$
希望有人有一个很好的解决方案 只有在禁用到期标头时,才会遇到相同的问题。有关于如何再次启用的提示吗?