As has already been stated, treating Googlebot differently to normal users and redirecting Googlebot only is generally not a good idea.
An alternative approach is to:
- Redirect all users/bots from
/app
to /dashboard
(the new "app")
- But include a link back to the old "app" from
/dashboard
that is not redirected. eg. /app?noredirect=1
that allows users to still use the old app if they wish.
- Make sure that
/app?noredirect=1
is not indexed by including an X-Robots-Tag: noindex
HTTP response header (or corresponding HTML robots meta tag). (You could simply noindex /app
, since it's being redirected anyway.)
The required directives in .htaccess
would be something like:
RewriteEngine On
# Redirect "/app" to "/dashboard", except "/app?noredirect=1"
RewriteCond %{QUERY_STRING} !^noredirect=1$
RewriteRule ^app$ /dashboard [QSD,R=301,L]
# Make sure "/app?noredirect=1" is not indexed
SetEnvIf Request_URI ^/app NOINDEX=1
Header set X-Robots-Tag "noindex" env=NOINDEX
The above redirects /app
to /dashboard
, but does not redirect /app?noredirect=1
. Any request to /app?noredirect=1
will include the X-Robots-Tag: noindex
header (this is optional if you are already setting the corresponding HTML meta tag).
However, there are potentially some additional complications, depending on how your app works and how/where your user login submissions are sent to. eg. You don't want to 301 redirect a users login POST request.