WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] slightly complicated 301 redirect issue (7 posts)

  1. Sallie Goetsch
    Member
    Posted 2 years ago #

    I have a client whose http://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,

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

    and

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

    Now they have

    http://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.

  2. 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/ http://newsroom.altabatessummit.org/media-info/
    Redirect 301 /media-contact/ http://newsroom.altabatessummit.org/media-info/

    If you want to get a little fancier...

    RewriteRule ^media-policy-and-procedures(.*)$ http://newsroom.altabatessummit.org/media-info/ [L,R=301]
    RewriteRule ^media-contact(.*)$ http://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.

  3. Sallie Goetsch
    Member
    Posted 2 years ago #

    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?

  4. Sallie Goetsch
    Member
    Posted 2 years ago #

    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.

  5. 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 :/

  6. jimesten
    Member
    Posted 1 year ago #

    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:
    http://domain.com/page.html
    http://anotherdomain.com/page.html

    New networked pages:

    http://domain.com/category/newpagename
    http://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 http://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

  7. jimesten
    Member
    Posted 1 year ago #

    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$ http://domain.com/programs/newpage/ [R=301,NC,L]
    RewriteRule pg2.html$ http://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.

Topic Closed

This topic has been closed to new replies.

About this Topic