• Hi,
    I’m having some trouble with parts of my site redirecting (301 according to curl -I)
    According the curl -I, they are only redirecting when there is not a forward-slash on the URL.
    This is not the case when viewed in a browser. In a browser, all subdirectories are redirected to the root domain.
    The only time they are not is when I navigate to a post from Admin > Posts > Edit Post > View Post.

    I am using @pothi ‘s git that’s found here: https://github.com/pothi/WordPress-Nginx (using the set up for sub-directories mu-dir-domainname.com.conf)

    I’ve changed only the parts need to be personalized to my setup (domain, etc.) AND I commented out the line rewrite ^/[_0-9a-zA-Z-]+(/wp-(content|admin|includes).*) $1 break; in the /etc/nginx/mu-dir.conf file (at least that’s how I understood the instructions in that file)

    It looks like the most solid configuration I’ve found, but this one issue I’m having some trouble figuring out.
    @pothi, if you see this, is there any advice you might be able to offer?

    Thanks,
    Chase

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Dexters Lab

    (@cohrac)

    UPDATE:
    After some more testing, not much has changed.
    The only thing I’ve found is that when I click from the admin area to view the subdirectory sites, it works. But if I copy that same URL and paste it into a new browser tab, it does not.

    I did the testing this morning on a computer that had not yet accessed the site.

    Please help!
    -Chase

    Thread Starter Dexters Lab

    (@cohrac)

    Hello,

    The default configuration file will work without commenting out any line. If you found the instructions elsewhere, then it may not work. That said, the 301 redirect is a strange issue. Did you try this configuration on a demo install with the default theme and no active plugins?

    Thread Starter Dexters Lab

    (@cohrac)

    Alright I figured it out. Thank you for your help here and at stack exchange @pothi. What it came down to was a little snippet of code I put in a while back to redirect a user to the home page if not logged in. Something I was no longer planning to use, but forgot that I put in.

    I really appreciate your help in this though. By disabling everything but wordpress (all plugins, caching, everything.) it still happened. I decided to change the theme used on my root site to the same theme used on the sub-sites and it resulted in an endless redirect. boom. That’s when the light turned on.

    Thanks again! -Chase

    And if anybody wants that code, here it is: it word pretty well! ??

    Redirect visitor to home page if not logged in:

    <?php if (
    !in_array($GLOBALS[‘pagenow’], array(‘wp-login.php’, ‘wp-register.php’))
    && !is_admin()
    && !is_user_logged_in()
    ) {
    wp_redirect(‘https://www.example.com/&#8217;, 301);
    exit;
    }
    ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Nginx Multisite subdirectory is 301 redirecting to root of site’ is closed to new replies.