Experience, to find home and uri
Home: http://web.tecnico.ulisboa.pt/~mcasquilho
Uri: http://web.tecnico.ulisboa.pt/~mcasquilho/text/php.php
Conclusion   The easiest way to get the root seems to be (see table) the association of http_referer with, namely, php_self. The problem, however, is that http_referer is not reliable. [This can be verified if you enter this page directly (writing its address in the address bar).] The method is to get a substring of http_referer till the string that is common with php_self. In this site, this common string would be "/~mcasquil".

1) ps: ~mcasquilho/text/php.php %  home: http://web.tecnico.ulisboa.pt:80/~mcasquilho %
2) hr: http://web.tecnico.ulisboa.pt/~mcasquilho/compute/ %  home: http://web.tecnico.ulisboa.pt/~mcasquilho %
Http_referer: http://web.tecnico.ulisboa.pt/~mcasquilho/compute/ (the calling page, if any)
Request_uri: /~mcasquilho/text/php.php PHP variable
Document_root: /var/www/web.ist.utl.pt --
• Http_host: web.tecnico.ulisboa.pt:80 Server variable
• Php_self: /~mcasquilho/text/php.php PHP predefined variable
Included from home (an example):
Hello, World !
You are connecting from IP = 193.136.128.114.
Browser: arquivo-web-crawler (compatible; heritrix/3.4.0-20190418 +http://arquivo.pt)
Copyright © 2020 All rights reserved.
 
 
Valid HTML 4.01! IST http://web.tecnico.ulisboa.pt/~mcasquilho/text/php.php
Created: ~1999 — Last modified:2007-01-16