From 1c0ddb567f6d8971d8a4a08c82843c14b82a1c3e Mon Sep 17 00:00:00 2001 From: Benjamin Date: Thu, 2 Jul 2026 11:06:20 +0200 Subject: [PATCH] Fixed rhpz.org again --- app/Http/Controllers/ShortLinkController.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ShortLinkController.php b/app/Http/Controllers/ShortLinkController.php index 89f217e..c89b3f5 100644 --- a/app/Http/Controllers/ShortLinkController.php +++ b/app/Http/Controllers/ShortLinkController.php @@ -6,6 +6,7 @@ use App\Models\Entry; use App\Models\News; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\URL; class ShortLinkController extends Controller { @@ -19,8 +20,15 @@ class ShortLinkController extends Controller 'l' => 'lua-scripts', ]; + private function routeOnMainDomain(string $name, array $params = []): string + { + URL::useOrigin(config('app.url')); + + return route($name, $params); + } + public function index(){ - return response()->redirectToRoute('home'); + return redirect()->away($this->routeOnMainDomain('home')); } public function legacy( int $wpId ) @@ -35,10 +43,10 @@ class ShortLinkController extends Controller if( $log->target_table == 'entries' ){ $entry = Entry::findOrFail($log->target_id); - return redirect()->route('entries.show', ['section' => $entry->type, 'entry' => $entry], 301 ); + return redirect()->away($this->routeOnMainDomain('entries.show', ['section' => $entry->type, 'entry' => $entry]), 301 ); } else if( $log->target_table == 'news' ){ $news = News::findOrFail($log->target_id); - return redirect()->route('news.show', ['news' => $news], 301); + return redirect()->away($this->routeOnMainDomain('news.show', ['news' => $news]), 301); } abort(404); @@ -48,13 +56,13 @@ class ShortLinkController extends Controller { if( $letter === 'n' ){ $news = News::findOrFail($id); - return redirect()->route('news.show', ['news' => $news], 301 ); + return redirect()->away($this->routeOnMainDomain('news.show', ['news' => $news]), 301 ); } $type = self::LETTER_TO_TYPE[$letter] ?? abort(404); $entry = Entry::where('id', $id)->where('type', $type)->firstOrFail(); - return redirect()->route('entries.show', ['section' => $entry->type, 'entry' => $entry], 301 ); + return redirect()->away($this->routeOnMainDomain('entries.show', ['section' => $entry->type, 'entry' => $entry]), 301 ); } }