问题
How can I get Referrer URL with PHP but the DIRECTORY only not the whole link (so without http://domain.com/) only the directory?
e.g:
Referrer: /contact/user/9443/
but not this
http://domain.com/contact/user/9443/
Thank You!
回答1:
I don't have PHP installed at the moment, but you could try using parse_url. This should do it I think:
parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
回答2:
What you're asking for is the referrer's path, which may or may not be on the current site, so in general you don't want to take only that.
afaik there's no special referrer-path for you; just parse out the path like so:
$referer_path = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
来源:https://stackoverflow.com/questions/23975216/how-can-i-get-referrer-url-with-php