2

I have a saas app, where users can login to the app from example.com/app. Now I have created a new version of the app which will be example.com/dashboard.

What I want to do is let Google know that the new app URL is example.com/dashboard, but I don't want to redirect /app to /dashboard because I want to allow old users to access /app.

How do I achieve that? I'll be grateful for your suggestions.

  • what is the web server you are using ? – Shyamin Ayesh Dec 26 '19 at 13:29
  • 1
    Why develop a new app if you're not going to let users use it? Google doesn't want something in this in search engine that isn't meant for users. – Stephen Ostermiller Dec 26 '19 at 14:17
1

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.

|improve this answer|||||
1

The solution you are looking for is using a canonical tag to signal Google which of the pages you want INDEXED and shown on Google.

A canonical tag transfers the "SEO" value of a URL to a different one but it keeps both online and accessible; a redirect (such as a 301) replaces one with the other.

What you want is to add a canonical tag in the example.com/app page pointing to example.com/dashboard according to this guide from Google and this guide from Yoast.

|improve this answer|||||
0

The simplest way to do this is to check the request user agent and redirect based on that.

Google have list of user agent strings that used for each type of request. You can check if the user agent is matching "Googlebot" then redirect.

If you are using Nginx as your web server you can do something like this.

if ($http_user_agent = "Googlebot") {
   return 301 http://example.org/dashboard$request_uri;
}

WARNING :
Google doesn't allow different redirects for users and Googlebot based on user agent. It calls it sneaky redirects, a form of cloaking. It's a black hat technique. Using this answer will get your site kicked out of Google.

|improve this answer|||||
  • 2
    Google doesn't allow different redirects for users and Googlebot based on user agent. It calls it sneaky redirects, a form of cloaking. It's a black hat technique. Using this answer will get your site kicked out of Google. – Stephen Ostermiller Dec 26 '19 at 14:16
  • Seems like I need to add warning. is it ok to copy part of your comment as a warning to my original answer @StephenOstermiller – Shyamin Ayesh Dec 26 '19 at 23:14
  • Sure, go ahead and copy it as a warning. – Stephen Ostermiller Dec 27 '19 at 0:32
  • Just appended that part to my answer @StephenOstermiller. :-) – Shyamin Ayesh Dec 27 '19 at 8:36
0

I think you are asking the wrong question and a redirect isn't the correct solution in your case.

It might be better to use Dynamic Rendering for your use case in which something like a dashboard that is dynamically generated is rendered statically for the user-agent of googlebot and others bots of their ilk. Basically, serve the public, non-specific version of the page.

But I also think that you should review your use case - a redirect shouldn't be necessary, as there is nothing wrong with a login page appearing in the Search Engine Results Pages.

That fits a particular search intent, namely the 'Navigational' search intent - a user searching for a particular page to log in. For example, if you Google 'Facebook Log in', there is a good change you will get https://en-gb.facebook.com/login/ in the Search Results because it fits the user intent.

Refer to this question: Is it a good practice to make login, reset password & register page indexable?

I would also take into account as to why you want the Dashboard to be indexed in Google. If this is user authenticated content, then it should not have any disoverable value for Google Seach and you are better off excluding it using the robots.txt file.

Disallow: /dashboard

|improve this answer|||||
-1

You just need to redirect googlebot PHP for exp

if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot"))
{
    // redirect 
}

For nginx exp

if ($http_user_agent ~ (googlebot) ) {
       return otherdomaine.com;
   }
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.