PHP
Public
Safe Redirect Allow List
Redirect only to known internal paths instead of trusting user input.
#php
#redirect
#security
#validation
PHP
<?php
$allowedRedirects = [
'/my-dashboard',
'/my-workspace',
'/my-billing',
];
$next = $_GET['next'] ?? '/my-dashboard';
if (!in_array($next, $allowedRedirects, true)) {
$next = '/my-dashboard';
}
header('Location: ' . $next);
exit;
Notes
Avoid open redirects by allowing only known local paths.