Server (website) 1 using this code:
<script type="text/javascript" src="http://server2.tld/script.php"></script>
on server 2 I would now like to get the domain name of the requesting server 1.
Is that possible?
Server (website) 1 using this code:
<script type="text/javascript" src="http://server2.tld/script.php"></script>
on server 2 I would now like to get the domain name of the requesting server 1.
Is that possible?
You can pass the url in the path to open server 2.
Server 1:
href=“server1.php?url='http://server2.tld/script.php'“
Anywhere in your server 1 code, you have a href
to open server 2. Replace the href
with the code at the top.
In your server 2, you have to get this code with this simple line:
$url = $_GET['url'];
So i have 2 valid options.
First Option
You could try
$referer = parse_url($_SERVER['HTTP_REFERER']);
$referer = $referer['host'];
but this is option only available if set by the client, so i might not be available.
Second Option
would be to create an api, and post the reference url via curl... technically its not the requested who figures out the ulr but the requester how send its... but this stackoverflow post should help you...
PHP + curl, HTTP POST sample code?
i hope this answers the question... if you have further questions pleas ask.