WordPress.org

Ready to get started?Download WordPress

Forums

New server, new domain - struggling with 301 redirects/htaccess (13 posts)

  1. sam_h1
    Member
    Posted 2 years ago #

    I've run into a problem, that despite all the googling and forum reading, I'm just not able to do myself. Unfortunately!

    Here is my situation and with your help, I'm really hoping I can sort it!

    - I had multisite running on serverA on domainA
    - I've since moved to serverB but still on domainA. All is running well!
    - The people who I previously worked for now want domainA back to use for something else, so I have to change the domain (but can keep and continue to run the multisite install)
    - I know I can run a find/replace on the DB in order to change all references to domainA to domainB
    - But what I really would love some help with is setting up the 301 redirects (maybe mod_rewrite?) in order to achieve the following:.
    Redirect all traffic from any of my current subdomains (516) to their equivalent on domainB (post > post)
    But also leave domainA so that my previous bosses can still use it for their next venutre (ie I can't have traffic to their site, redirecting to mine!)

    Perhaps the solution is very simple? (I may be able to keep an htaccess file on domainA's new server if I ask them nicely) I just really don't know where to start!

    All help would be gratefully received, thank you :)

    Sam

    (this has also been posted at WPTavern: http://www.wptavern.com/forum/wordpress-mu-multisite/2343-new-server-new-domain-struggling-301-redirects-htaccess.html where I'll update with the response)

    Thank you again!

  2. You will definitely need to have a rewrite rules on *their* site redirecting any of the subdomains.

    There's no way traffic to their new site will ever hit your server. They are going to get all the bounced traffic so it's also in their best interests to put that rewrite rule there.

    Ipstenu is the Queen of Htaccess so I'll let her tackle that part when she gets back.

  3. Yes, you need something on SiteA to send back to SiteB.

    So if you're going http://sitefoo.domainA.com to http://sitefoo.domainB.com and all the permalinks internally are the same then it's pretty painless:

    RewriteCond %{HTTP_HOST} ^sitefoo\.domainA\.com
    RewriteRule ^(.*) http://sitefoo.domainB.com/$1 [L,R=301]

    The problem is you're talking 516 subdomains. That's a pain in the ass no matter how you look at it. You MIGHT be able to redirect it via DNS and send sitefoo from DomainA to sitefoo.domainB.com which would put less stress on DomainA at the end of the day.

  4. sam_h1
    Member
    Posted 2 years ago #

    Thanks to both of you!

    So Ipstenu, I will need to do that for all my subdomains? (i don't actually mind - it's a pain, but at least it will work!)

    I'll speak with the people who will be using domainA going forward as you're both right, it's in their best interest to make sure this works correctly too

    Can I just confirm before I go ahead, these changes will be ok with multisite - ie it will be a redirection at post level ie the htaccess rule will redirect a link to a blog post on the old domain, to the same blog post on the new domain (permalink structures are remaining)

    I am also thinking of using a plugin like Smart404 to catch anyone who happens to land on a duff redirection for whatever reason!

    Sam

  5. Yes, they work fine with MultiSite :) I grabbed that from my live server.

    Go to code.ipstenu.org and it'll magically move you to tech.ipstenu.org ;) All via .htaccess. You can redirect anything.

  6. sam_h1
    Member
    Posted 2 years ago #

    Good times! I just had a little look around your site, how I've not come across it before I don't know!

    This is sort of related to this whole thing and if you wouldn't mind casting your eye over this link I've really appreciate it. The link outlines the steps I need to make in order to actually now change to domainB...and I want to confirm that they cover everything: http://www.realisingdesigns.com/2010/09/16/moving-the-domain-of-a-wordpress-multisite-install/

    Thank you!

  7. Yes, that's pretty much it. You'll have to run the SQL command for each wp_x_posts tables.

    Bear in mind: If your domain names are of different lengths, there is a possibility you will lose your widget settings on your sites. This is due to serialization and how the absolute length of your URL is recorded in weird places. Which is why we tell you run a blanket SEARCH for olddomain, but replace them carefully.

  8. sam_h1
    Member
    Posted 2 years ago #

    Ok - thank you for that advice

    I want to do my best to update the DB but I imagine that if I have the correct 301 in place then any records in the DB that can't be updated (or I miss) should still be covered by the redirect?

    Thank you again for your help - I'll ping you the final domain when it's all done so you can see if all the effort was worth it ;)

  9. Not really, the database you're changing is the one that will be on DomainB, and because of THAT, it has to be all internally correct, or wackiness ensues. The posts tables, yes, a 301 will cover, but the other tables in that article (wp_blogs etc) cannot be 301d.

  10. sam_h1
    Member
    Posted 2 years ago #

    Hi Ipstenu

    I seem to be having a couple of problems. By way of a test, I've set up the redirect from domainB to domainA before I formally change the URL to domainB (DNS records for both are setup on my own server and I've also setup a directory on my server in order to host the htaccess file for domainB in order to do the test...it's just a folder with an htaccess file in it)

    Here's what the htacess file contains:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domainB\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domainA.com/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^subdomain\.domainB\.com
    RewriteRule ^(.*) http://subdomain.domainA.com/$1 [L,R=301]

    (please bear in mind that this is the reverse of what I originaly described in the opening comment in order to test!)

    What I've found is that domainB successfully redirects to domainA

    However, subdomain.domainB.com redirects only to the "Default Web Page" that WebHostManager spits out

    I can only imagine that it's a DNS config error, however I wouldn't know where to start to fix it!

    (if you'd like to see the actual domains, I'd happily email them over to you!)

    Cheers - do you have a wishlist btw?

    Sam

  11. However, subdomain.domainB.com redirects only to the "Default Web Page" that WebHostManager spits out

    Well ... does subdomain.domainA.com exist?

  12. sam_h1
    Member
    Posted 2 years ago #

    Ha! Yes, it exists!

  13. If subdomain.DomainB.com also exists, and is NOT redirected to domainb.com (which is what you do in MultiSite - all roads lead to Rome), then you'd have to put a redirect in the SUBDOMAIN folder.

Topic Closed

This topic has been closed to new replies.

About this Topic