Fixed rhpz.org again
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user