• Resolved Sallie Goetsch

    (@wpfangirl)


    I have a client whose https://www.clientdomain.org site runs on Server X, managed by their IT department. I believe Server X is a Windows Server, but I don’t know for sure.

    The WordPress Multi-site installation we’re managing is on a Linux server (Server Y) hosted someplace else entirely and the specific sub-site we have the issue with is mapped to subdomain.clientdomain.org.

    The client used to have two pages for their PR stuff,

    https://newsroom.altabatessummit.org/media-contact/

    and

    https://newsroom.altabatessummit.org/media-policy-and-procedures/

    Now they have

    https://newsroom.altabatessummit.org/media-info/

    “Oh,” I said brightly, not realizing what a TREMENDOUS pain this is with Multi-site, “We’ll just set up some 301 redirects in your .htaccess file.”

    Well, I haven’t been able to figure out how to do that. Read a few things here in the forums and elsewhere online, but nothing worked. I suspect that having the main domain actually on a different DNS doesn’t help at all, but don’t know enough about it to be sure.

    In any case I don’t need regex or anything fancy, just for those two URLs to point to that one new page.

    Can anyone here help? I am reluctant to install plugins because there’s a lot of custom code on this site and I’d rather keep potential conflicts to a minimum, but I’m willing to try anything with a good chance of working.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You want both the old pages to point to the new ones? That is pretty easy, even with Multisite ??

    Rule 1) Always put your 301s and other customizations above the WordPress htaccess calls.

    Rule 2) KISS ??

    Redirect 301 /media-policy-and-procedures/ https://newsroom.altabatessummit.org/media-info/
    Redirect 301 /media-contact/ https://newsroom.altabatessummit.org/media-info/

    If you want to get a little fancier…

    RewriteRule ^media-policy-and-procedures(.*)$ https://newsroom.altabatessummit.org/media-info/ [L,R=301]
    RewriteRule ^media-contact(.*)$ https://newsroom.altabatessummit.org/media-info/ [L,R=301]

    That should cover trailing slash or not. The only reason that would be problematic is if you have those pages on other sites as well.

    Thread Starter Sallie Goetsch

    (@wpfangirl)

    I took over this project two years in, and there are 6 sites, so I’ll have to go see whether those pages exist on the other sites. (Oh, someone PLEASE invent a way for the network admin to log into all the dashboards at once. PLEASE.)

    Ah. Small snag. Five of the six sites have /media-info/ pages. I don’t know whether they also had older pages that need redirecting, though. The client has not mentioned any. (As the client is not known for rigorous testing, this means nothing.)

    So maybe we DO need a regex?

    Thread Starter Sallie Goetsch

    (@wpfangirl)

    Okay, I checked with the client. The old pages don’t exist on the other sites, so your solution will work. And it DOES work. You, @ipstenu, are a genius. I was going to make a donation for the brilliant Multi-site e-book you and @andrea_r wrote anyway, but will run over and do it now.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Glad it worked! You can still redirect if it’s on multiple sites by prefacing each rewrite with this:

    RewriteCond %{HTTP_HOST} ^newsroom\.altabatessummi\t.org

    Sadly I’ve never been able to make it work right as a section, so I ended up with a slew of ‘Rewrite cond’ followed by the rule, over and over :/ I’m sure there’s a better way!

    (Oh, someone PLEASE invent a way for the network admin to log into all the dashboards at once. PLEASE.)

    The ‘problem’ is browsers and cookies. Subdomains are ‘kind of’ separate domains so the cookies are, for your safety, not allowed to cross domains. You can be logged in to all at once, but the cookies/login may expire :/

    Does anyone actually have this working under the following scenario:

    1. Old standalone sites migrated to a multisite network
    2. Old sites have pages with same name so need to distinguish between domains on the new networked sites
    3. New page names are different from old page names..
    4. I have roughtly a dozen of these for each domain .. so already need hundreds…

    Example:
    Old pages:
    https://domain.com/page.html
    https://anotherdomain.com/page.html

    New networked pages:

    https://domain.com/category/newpagename
    https://anotherdomains.com/category/newpagename

    I have tried matching http host with a rewrite condition to no avail. The only way I’ve been successful is a vanilla:

    Redirect 301 oldpage.html https://domain.com/category/newpage

    … but that doesn’t cut it because the old pages have the same name on all the old sites. I’ve tried several redirect plugins as well.

    I’ve love to the see the .htaccess file of a fully working site that has the same scenario!!

    thanks,

    Jim

    I have finally resolved this one .. if anyone is in similar situation, please contact me. Part of the problem appears to have been in the order of instuctions in the WP multisite .htaccess file and which lines had the [L} directive

    Basically, the working format is:

    RewriteCond %{HTTP_HOST} ^domain.com [OR]
    RewriteCond %{HTTP_HOST} ^www.domain.com
    RewriteRule page.html$ https://domain.com/programs/newpage/ [R=301,NC,L]
    RewriteRule pg2.html$ https://domain.com/programs/newp2/ [R=301,NC,L]

    I did note elsewhere that someone had found they need to repeat the RewriteCond statement before each rule, but I have now got the first 6 domains done using only the pair of conditions for www vs non www and then just the rules (about a dozen per domain) for each page where I needed to do the redirection.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘slightly complicated 301 redirect issue’ is closed to new replies.