How reliable is a 301 referer redirect? Are there any other alternatives? - http-status-code-301

I need to be able to display 2 differing landing pages depending on the URL is user is coming from e.g. if user A comes from www.domain.com/qwe, he/she is redirected to page.domain.com and if user B comes from www.domain.com/rty he/she is redirected to page.domain.com. Depending on where they came from page.domain.com would show differing content. The redirection occurs as 310 redirect at the server level i.e. the web server implements the 301 redirect.
How reliable are 301 redirect referers?
Is there a better way to achieve the same result using a different method and if so what is it?

Related

301 redirects specific pages with get parameters and non-specified pages

I have my old website old.com and my new website new.com. I want to create 301 redirects in the .htaccess for some specific pages and some generic 301 redirects as well.
Get parameter redirects:
old.com/a/test?u=blah redirect to new.com/a/test?u=blah
old.com/a/test redirect to new.com/a/test
old.com/a/test.php?u=blah redirect to new.com/a/test?u=blah
As you can see the only thing that changed was the domain name. How can I redirect users to the new domain but also keep their get parameter the same. So regardless of what u=, it forwards the u= parameter to the new URL. Of course if there is no u=, it still redirects to the page (as per second example)
Get parameter without putting get parameter
old.com/a/foo?u=blah redirect to new.com/a/foo
old.com/a/foo redirect to new.com/a/foo
old.com/a/foo.php?u=blah redirect to new.com/a/foo
As you can see, it directs to the new domain but does not carry the u= parameter. Same applies for the second example.
Redirect Directory
old.com/blog redirect to new.com/blog
old.com/blog/23452/how-to-tie-a-tie redirect to new.com/blog
If the site is in the blog directory, regardless of what comes after the blog directory in the URL, it always redirects back to new.com/blog
I am unsure on how to do these types of specific redirects. I only understand how to direct a specific URL like so Redirect 301 old.com https://new.com

Partial 301 redirects & SEO strategy

This is somewhat of a subjective question. But would like the communities take on this. My client is doing a site split. www.domain1.com will turn in to -- www.domain1.com + www.domain2.com. I know this isn't typically advisable from an SEO perspective, but they are doing it for legal reasons.
Our plan is to only rip out the product pages on www.domain1.com and add those on www.domain2.com everything else on domain1 will stay and everything else on domain2 will be original content. So here's the question, still a good idea to do single page 301 redirects for the pages that are transferred?
www.domain1.com/apples > www.domain2.com/apples
I know that's a bit open-ended, without a ton of detail, but if you have specific examples of where you've done something similar, I'd be curious to know what worked/didn't.
Yes, with a clarification: http 301 is the best for your purpose, because it means permanent redirect (good for SEO, you pass the page and domain authority, link juice...); instead a 302-redirect (http 302) means a temporary redirect, you have no time limits but all the SEO value won't pass! For your purpose, you don't want that.
In general, all pages should be redirected with http 301. Aniyway, with data analysis you can make a decision: if you have a page unuseful, with no traffic, it doesn't need to be redirected, you can use http 404 or http 410 (you can build also a custom 404 page!).
The last thing, must avoid multiple redirects, for example: instead of site1-->site2-->site3 you just need to do: site1-->site3. The reason is each redirect hurts loading speed (also the most common and useful redirect, from http to thhps!!). You just need to avoid multiple ones.

Setting up 301 redirects for multiple domains merging to single domain

I've got a tricky situation where four different websites are now merging into a single site. I'm trying to figure out the best way to handle 301 redirects for old URLs from these sites.
Here's an example for illustration. Say I have these four sites:
https://red.com
https://blue.com
https://green.com
https://magenta.com
And they're all now going to be living just at https://red.com.
Each of these sites had a "Team" page...
https://red.com/team/
https://blue.com/team/
etc.
Once I've pointed all the URLs to the same place, I'd like to see if someone tried to enter one of the previous URLs, and direct them to a specific new place on the site, e.g.:
URL Entered: https://blue.com/team/
301 Redirect: https://red.com/blue/team/
URL Entered: https://green.com/team/
301 Redirect: https://red.com/green/team/
etc.
Since folks may be coming from multiple different domains, I can't use standard relative 301 redirects in .htaccess for this. I'd like to just be able to point the DNS for these other domains to go straight to red.com, and then handle the 301 redirect logic there.
Any ideas on how to handle this?
You can simply use 302 temporary redirect rather than using 301 which is permanent.
** Also don't forget to clear previous 301 redirection caches on your web browser; if used.

If I set up HSTS on a domain that already implements a 301 redirect, which will take precedence?

Ok, so the scenario is that we have a http domain which currently uses a 301 redirect, we want to change this domain to no longer 301 redirect, and instead to be the main domain for said website.
The problem here is that 301 redirects are cached forever, so this isn't really feasible.
We do however want to change the domain to run on https only, and the https domain doesn't have any redirect set whatsoever.
So I'm wondering if I implement HSTS on a domain that already implements a 301 redirect, will the user be forwarded to the HTTPS version of the page (which currently has no redirect in place). This is presuming that they've already got the 301 redirect cached in their browser.
Unfortunately I can't seem to find any information about whether HSTS or the cached 301 redirect would take precedence.
HSTS should take precedence as that happens in the browser - before any message is sent (or any cached redirect is used in place of a request being sent).
However this is easily enough tested so would suggest you confirm it yourself.
And yes I really wish browsers would honour cache expiry times of 301s and/or expiry them periodically. Pretty annoying.

Two URLs, Same Server / Files?

I would like to have two URL (ex: www.mycoolsite.com and www.myfunsite.com) and point them to the same server, and use some of the same files. I want a different homepage and css for each site, but evernthing else would be identical.
My webhost allows me to 'park' a domain, but that changes the URL that the user sees and I'm not sure if there is anyway to detect which URL the user originally entered.
Any ideas how this can be accomplished?
I think you want a HTTP 301 permanent redirect.
Example

Resources