Here's the code you need to include in your .htaccess file, in order to redirect your domain to another domain, while hiding the redirect from popular backlink checkers.
You can add extra user agents that you want to block on line 2 of these snippets.
Simply copy/paste the snippet that you want, update the target URL on the final line, save it in a text file called .htaccess and upload it to your site's public_html folder
1 - Redirect All Pages to All Pages
With this code snippet, all URLs on domain1.com will redirect to targetdomain.com - eg domain1.com/contact will redirect to targetdomain.com/contact
If you don't want to hide this from backlink checkers, you can remove the second and third lines from this snippet.
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} (rogerbot|mj12bot|dotbot|gigabot|ahrefsbot|semrushbot|majestic-12|majestic-seo) [NC]
RewriteRule (.*) - [F,L]
RewriteRule ^(.*)$ https://targetdomain.com/$1 [L,R=301,NC]
2 - Redirect All Pages to a Single Page
With this code snippet, all URLs on domain1.com will redirect to
targetdomain.com/acquired - eg domain1.com/contact and domain1.com's homepage will all redirect to
targetdomain.com/acquired
If you don't want to hide this from backlink checkers, you can remove the second and third lines from this snippet.
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} (rogerbot|mj12bot|dotbot|gigabot|ahrefsbot|semrushbot|majestic-12|majestic-seo) [NC]
RewriteRule (.*) - [F,L]
RewriteRule ^(.*)$ https://targetdomain.com/acquired [L,R=301,NC]