Redirect homepage with htaccess, except if I enter the link adding “/home”

A quick way might be to simply append a query string to the URL in order to prevent the redirect (eg. ?noredirect) – simply appending a query string should not prevent the old homepageA from displaying.

You’ll presumably want to prevent indexing of the ?noredirect URL. This can be achieved by sending an X-Robots-Tag: noindex HTTP response header.

However, any user typing this URL (ie. ?noredirect) will be able to access the old homepageA, regardless of whether they have visited homepageB first.

For example:

# Redirect homePageA to homepageB, when the query string is not "noredirect"
RewriteCond %{QUERY_STRING} !^noredirect$
RewriteCond %{HTTP_HOST} ^(www\.)?homepageA\.ar
RewriteRule ^$ https://homepageB.ar/ [R=301,L]

# Send the X-Robots-Tag noindex header when query string is "noredirect"
RewriteCond %{QUERY_STRING} ^noredirect$
RewriteRule ^ - [E=NOINDEX:1]
Header set X-Robots-Tag "noindex" env=REDIRECT_NOINDEX

There’s no need to backslash-escape colons, slashes and dots in the RewriteRule substitution string. And the RewriteRule pattern ^$ is the same as ^/?$ when used in .htaccess.

Assuming you are on Apache and you are internally rewriting the request to the WordPress front-controller (the standard WP .htaccess directives) then you need to check REDIRECT_NOINDEX in the Header directive, despite setting the NOINDEX env var in the preceding RewriteRule directive. (The rewrite engine triggers a “loop” and the NOINDEX env var is renamed to REDIRECT_NOINDEX.)

You’ll need to clear your browser cache before testing and preferably test first with 302 (temporary) redirects before making it a 301 (permanent) redirect.