Jump to content

Finding out the current page URL


Cless

Recommended Posts

It there a way to find out the current page URL? Well, I know you can, but...

 

Basically, I need to be able to find the actual URL you are on. For example, if you are on "www.blah.com/pie.php", I want it to return that value. Only exception is, for example, if you are using a web proxy or something, the site is displayed in an iframe.

 

Let's say the URL of the proxy you are using is, like ", and it is displaying "www.blah.com/pie.php" through a proxy (meaning it is showing in an iframe, usually). The actual URL is "www.blahproxy.com/blah.com/pie.php".

 

So basically, if you viewing the page normally, it will return "www.blah.com/pie.php", elsewise, it will return "www.blahproxy.com/blah.com/pie.php".

 

Note: I know that not all proxies use iFrames, I was just using it as an example.

Link to comment
https://forums.phpfreaks.com/topic/137963-finding-out-the-current-page-url/
Share on other sites

You can use a much better script like, which always returns the correct url and its much more reliable.

 

<?php
function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.