isMethod('GET')) { try { $path = '/' . ltrim($request->path(), '/'); $redirect = cache()->remember('seo_redirect_' . md5($path), 300, function () use ($path) { return SeoRedirect::where('from_path', $path)->where('is_active', true)->first(); }); if ($redirect) { SeoRedirect::where('id', $redirect->id)->increment('hits'); cache()->forget('seo_redirect_' . md5($path)); return redirect($redirect->to_path, $redirect->type); } } catch (\Throwable $e) { // DB/cache hatası — redirect yerine normal akışa devam et, site çökmesin \Illuminate\Support\Facades\Log::error('SeoRedirectMiddleware DB error: ' . $e->getMessage()); } } return $next($request); } }