How can I get Referrer URL with PHP?

对着背影说爱祢 提交于 2019-12-24 07:35:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!