Search code examples
phpwordpresshttp-redirect

Any idea why redirect isn't working in Wordpress?


a redirect_to from the wordpress software isn't working

domain.com/wp-login.php?redirect_to=https%3A%2F%2Fforums.domain.com%2F

which should then return to the sub directory of forums

However it simply goes to domain.com/wp-admin

I have disabled all plugins, tried a different browser, tried both an admin and regular user.

I have also upgraded to 6.3.1 - tried on both this and the old version.

I run cloudfare, but also disabled this.

I also have a redirection plugin installed - but this works fine (also disabled to check a conflict)

I am at a loss to figure out why this is failing


Solution

  • The above didn't work.

    instead

        function my_allowed_redirect_hosts( $hosts ) {
        $my_hosts = array(
            'forums.domain.com',
            'www.domain.com',
            'domain.com',
        );
        return array_merge( $hosts, $my_hosts );
    };
    add_filter( 'allowed_redirect_hosts', 'my_allowed_redirect_hosts' );
    

    should work.

    The difference being the word array missing in the first example.