how to make a redirect url /random
to /d/1234
or /d/2345
or something else that can redirect discussion urls randomly and not redirect to non-existent discussions (page 404)
I've tried to make like this
if (!empty($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/random') !== false) {
exit(header("Location: https://" . $_SERVER['SERVER_NAME'] . "/d/" . random_int(1, 2500) . "", true, 302));
}
but the problem is it can't filter non existent discussion (404)
anyone can help?