The URL path (the part in the https…) is appended to the document root (the part in the file system “var/www…”) by default, behind the scenes. So a typical setup would be what you have with putting your file in var/www/html and, assuming the document root is actually set (in the Apache web server, another assumption since I don’t know what you’re using) to that path, then it would make your URL simply https://myservername.com/phpinfo.php as you have in your second example.
Could you show a directory listing of that folder on the server, just to clear up a simple typo or upper/lowercase mixup?