Support » Networking WordPress » using wp_redirect on multisite subfolder site

  • Hi,

    I have a multisite setup with subfolders. There are 3 sites installed which will use the same theme but in English, French and Dutch.

    I want to use wp_redirect in the header of the theme so that the user is redirected to one of the sites based on a cookie that is set when they click on a language option in a popup.

    The redirect works fine on the english site which has the path ‘/’ but not on any of the other sites which have paths – ‘/fr/’ and /’nl/’

    I’ve also tried redirecting using header("Location:"); and that doesn’t work either.

    It literally does nothing!

    Is it because the sites are subfolders rather than sub directories?

    I’m stumped.

    Thanks for help


Viewing 7 replies - 1 through 7 (of 7 total)
  • What’s the full redirect code you’re using?

    I’ve tried all sorts of variations of the following

    <?php wp_redirect( '', 301 ); exit; ?>

    It works on the main domain I.e.

    But not on any of the other sites I.e

    The exit part of the code works as it stops any of the code after the statement executing.

    Any ideas?

    Sorry, forgot to put code in tags.

    Sorry, let me rephrase.

    What’s the WHOLE code you’re using, to detect cookie, etc. Put it up on pastebin or github and link to it 🙂 We may be able to debgu it that way.

    Hello again,

    Well I’ve removed the cookie code and conditional statements for now to try and get the redirect work in the simplest way. So the that is the whole code. I’ve also tried it in the WP 2013 default theme. So if you imagine the header.php file in 2013 theme, then immediately below the head tag i placed

    <?php wp_redirect( '', 301 ); exit; ?>

    I’ve also tried using

    <?php header("Location:"); exit; ?>

    Which doesn’t work either. This makes me think it is due to the subfolder setup on the multisite that stops it working. I am wondering if using subdomains instead would work?

    Thanks for your help


    No, it shouldn’t matter.

    Are you sure you edited the right theme?

    Yes quite sure. The “exit” code stops the rest of the page loading so you can tell.

    I set up a test multisite to try it on a clean install. Interestingly is doesn’t even work on the root path (‘/’)
    The second site is

    So then I went back to the original site I am working on and cloned the root path site using NSclone. It works on the clone. i.e. (

    I have no idea why. There is something about the root path site that wp installation that makes it work… Very strange.


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘using wp_redirect on multisite subfolder site’ is closed to new replies.