Domain Mapping .htaccess redirect 301

Hi,

I have a multi-site with domain mapping plug in. We uses sub-domain network set up for mini-sites. We just mapped site1.domain.com to http://www.anotherdomain.com.

I'm wondering how do we set up redirect 301 in htaccess for old URLs from http://www.anotherdomain.com?

For example i want to redirect http://www.anotherdomain.com/?id=160&sid=55 to http://www.anotherdomain.com/first_page/

How do i do that in my htaccess file ?

Thanks

  • Nastia
    • Support Rock Star

    Hello Julie Woempner , I hope you are doing well today!

    If you wish to redirect to another file on your domain please try to use the following code:

    Redirect 301 /oldfile.htm /newfile.htm

    Please keep the original copy of the .htaccess file so is something goes wrong, you can always restore it back.

    I hope this helps!

    Kind Regards,
    Nastia

    • Hendricks Regional Health
      • WPMU DEV Initiate

      Hi Nastia, sorry I don't think I made my question very clear last time. We have a Wordpress multisite with 3 mini sites:

      domain.com (network root site)
      site1.domain.com
      site2.domain.com
      site3.domain.com

      Now we just finish a custom built site on site1.domain.com and used the Domain Mapping plugin to map:

      site1.domain.com -> http://www.anotherdomain.com

      There are some older urls being indexed from http://www.anotherdomain.com before we made the Domain Mapping, and now we would like those to be redirected.

      For example:

      older url: http://www.anotherdomain.com/?id=150&sid=5

      needs to redirect to:
      new url: http://www.anotherdomain.com/newpage

      Yesterday after reading a few online forums, we played with the htaccess for awhile. The tricky part about making these redirects are:

      -Since this is a multisite setup, all of the sites are using a single htaccess file. Therefore, we need to ensure these redirect only works for http://www.anotherdomain.com (aka. site1.domain.com, because is being domain dapped)

      -These older index urls are query string (www.anotherdomain.com/?id=150&side=5)

      So for this is what we have for redirects:

      RewriteEngine On
      #RewriteBase /
      RewriteCond %{HTTP_HOST} ^(www\.)?anotherdomain\.com [NC]
      RewriteCond %{QUERY_STRING} id=150 [NC]
      RewriteCond %{QUERY_STRING} sid=5 [NC]
      RewriteCond %{REQUEST_URI} ^/$
      RewriteRule ^$ http://www.anotherdomain.com/newpage/? [R=301,NC,L]

      Do you think you could come up with a better solution? Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.