htaccess Redirect Assistance Please

Joined
Nov 15, 2019
Messages
8
Likes
4
Degree
0
Hi all,

I am hoping to get some assistance with creating an effective htaccess redirect please.

The situation is that I am redirecting site B to site A. Not all URL's are the same so I have created the redirects on a URL by URL basis.

Here is what I am using:

Code:
Redirect 301 / https://websitea.com

Redirect 301 /page-from-website-b https://websitea.com/page-from-website-a

Redirect 301 /category-without-category-in-permalink https://websitea.com/category/similar-category-on-site-a


These redirects are working fine but the problem I am having is that because the root domain of website b has backlinks pointing to the non-https version, I have a little redirect chain going:

Code:
http://websiteb.com --> https://websiteb.com --> https://websitea.com

I also tried the following format to avoid the above issue:

Code:
RewriteRule ^page-from-website-b[/]?$ https://websitea.com/page-from-website-a [R=301,L]

But was unsure how to add in the root domain to root domain redirect without messing up the rest.

Any assistance would be greatly appreciated!
 
You don't appear to have a problem as far as I can tell.

Google will follow a redirect chain of up to 5 leaps before they give up. And then they return and finish crawling the leaps later. You have two leaps so it's not an issue.

I've been anal-retentive about this and set up a catch all redirect to send http://www and https://www and http:// all to https:// in one leap. It took me a while to figure out and ultimately was just a waste of time.

Your final RewriteRule seems like it should handle http:// and https:// scenarios with or without the trailing backslash, especially if you're using something like Wordpress which is going to redirect the http:// version to https:// first anyways.

Have you tried it to confirm you end up at the right destination if you do a the http:// variation on websiteb?
 
Okay great thanks.

Yes, I have tested and do end up at the right final destination so will leave the redirects as they stand.

Appreciate the feedback!
 
Back