I was not sure of the best way to describe this in the title but my scenario is the following:
Every page on our site requires authentication and will redirect unauthenticated users to a login page from pretty much any other url.
We do not want the login page link to show up as a search result in google since the base url (site.com/login) is not valid. We are using openid-connect for authentication and the login page url will always have a query string containing additional data for openid such as the redirect uri and a session specific state. Therefor, we dont want various variations of login urls showing up in google search results which will not be valid when clicked.
Ideally, we would be able to have only the root url appear in the search results (www.site.com). Clicking on this link will properly route the user to the login page which contains the proper query string.
We currently have this configured so that it almost works how we want. We have added the login page base url and a few other "public but invalid without context" url to our robots.txt and currently a google search does turn up only the root url of the site.
Functionally this is great, however, there is no description beneath the link other than "No information is available for this page." This I believe is due to google following the redirect and finding that the destination is excluded via robots.txt.
The login page does contain the meta description we want to show up under the search result. My question is, can I somehow instruct google to use that description for the root url without having the login page show up as a search result?
I have read about the use of a
<link> with rel="canonical" but it seems that using a url which always returns a 302 as the canonical link can cause issues.
I feel like there must be other sites using a similar login model which handle this properly but I have little experience working with search engines like this and have had no luck finding information about this scenario.