How to Extend the List of Allowed Domains for wp_safe_redirect()
It is one of my shortest tutorials ever. But I decided to publish it anyway because I didn’t find any information about it anywhere.

wp_safe_redirect()
allows to redirect only to this domain excluding subdomains.add_filter( 'allowed_redirect_hosts', 'misha_extend_allowed_domains_list' );
function misha_extend_allowed_domains_list( $hosts ){
$hosts[] = 'wordpress.com';
$hosts[] = 'misha.rudrastyh.com';
return $hosts;
});
That’s all 😁
Read also

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Hello Misha thanks for the example. I’m trying to use the login form in an external (codeigniter/CI) application. It runs in a folder *under* the wordpress site: WP URL: something.com/wp, CI URL: something.com/wp/portal. I added the whole CI URL in the CI app but not sure it does work. Should this work for a subfolder? Thanks!
This was very helpful in getting my logout redirect to go to the next link in a logout chain. Thanks for taking the time to post it!