<?php
declare(strict_types=1);

$target = 'blog.php';
$params = [];

if (isset($_GET['q'])) {
    $params['q'] = (string) $_GET['q'];
}

if (isset($_GET['category'])) {
    $params['category'] = (string) $_GET['category'];
}

if ($params !== []) {
    $target .= '?' . http_build_query($params);
}

header('Location: ' . $target, true, 301);
exit;
