How can regular expressions be used in PHP to redirect URLs effectively?

Regular expressions can be used in PHP to match and redirect URLs effectively by using the `preg_match()` function to check if a URL matches a specific pattern, and then using `header('Location: new_url')` to redirect the user to a new URL if the pattern is matched.

$url = $_SERVER['REQUEST_URI'];

if (preg_match('/old_url_pattern/', $url)) {
    header('Location: new_url');
    exit();
}