Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Why would you want to change what WP does with the address? Doing so would likely foul up the multisite functionality in all sorts of ways.

    Why don’t you simply extract the data you need out what WP returns and build your own proper destination URL? PHP’s preg_match() should do that easily. Or maybe even easier is to explode() what’s returned on the dots and build your URL from the last 3 elements.

    Thread Starter ccgauvin94

    (@ccgauvin94)

    I’m not sure entirely what you mean.

    Basically I just want to redirect after login to something other than the admin panel. It seems like the best way to do this is to use the filter that’s already in place. Problem is, that only appends the page to the site’s home URL. I want to redirect to an entirely different multisite altogether.

    I’m not positive how preg_match() would help me. Doesn’t that just check for a string and return a logic value?

    Moderator bcworkz

    (@bcworkz)

    preg_match() does indeed check a string and return a boolean. But it can do much more when you provide a third $matches argument. $matches will contain any regexp matches that where captured by using parenthesis in the regexp .

    preg_match('!.*\/www\.(.*)!', 'www.mymultisite.com/www.mysite.mymultisite.com', $matches);
    header("Location: http://{$matches[1]}/");
    exit();

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect to External URL’ is closed to new replies.