Php – Obtain actual browser URL in PHP

PHP

I need to retrieve the actual URL that the user see's in their browser. I have an Ajax request running at page load. Hence, the regular $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] expression returns the request URL of the Ajax request instead of the actual URL in the browser.

Any idea how to get this?

Best Answer

You could pass it up from javascript in your ajax request, using window.location.href.

Also, it's likely that $_SERVER['HTTP_REFERER'] will contain the browser's current location.