Hello,
That's a quite uncommon thing to do for a webserver unless you want only web browsers to access it.
By blocking HTTP/1.1 and only allowing HTTP/2, you would be blocking all automated APIs from native computer programs.
Native computer programs that rely on their host system's built-in HTTP APIs will fail to connect.
WinHttp on Windows for example simple always does HTTP/1.1, so if you block it then you block all desktop programs other than Firefox/Chrome/Edge from connecting to your website at all.
If you want to do it anyway, then it's with these CGI variables from the CGI documentation page:
If the current request is served over a HTTP/2 connection, the following variables are also available:
HTTP2: It is set to on.
H2_STREAM_ID: A number uniquely identifying the stream within the HTTP/2 connection on which the current request is being served.
H2_STREAM_TAG: A tag uniquely identifying current stream within all HTTP/2 connections of the server. The tag is made of two numbers separated by a hyphen character.
And for the custom error page, there are two variables that are used for backing up the original virtual path & response code & reusing them in your error page:
Example 6-1. Using the redirection information in scripts
If a script is invoked after an internal redirection, it can retrieve some interesting information from the environment about its parent request such as:
REDIRECT_SCRIPT_NAME: The virtual path of the parent document.
REDIRECT_STATUS_CODE: The status code of the parent request. It is useful when writing scripts that generate custom error pages.
So, in your URLRewrite verify that is variable 'HTTP2' is equal to the text 'on'.
If not, then report the error code '505 - HTTP Version Not Supported' to the client.
Then you simply customize the error page for the 505 code in your host's Custom Error Pages section.
And lastly, in your host's 'General :: Advanced Parameters :: HTTP/2 Parameters' remove the '*/nph-*' row from the 'HTTP/1.1 Required' list.