hellonoko Posted February 17, 2007 Share Posted February 17, 2007 I am trying to get the full query string from the browser. I have tried a few things. HTTP_REFERER / PHP_SELF / REQUEST_URI But id like to capture the full complete URL. Any ideas? Thanks, Ian Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 17, 2007 Share Posted February 17, 2007 There is no set variable that holds the entire URL. However in order to get the entire URL you will need to "stitch" several seperate variables together. Here's an example: <?php $myURL = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; echo $myURL; ?> Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 17, 2007 Author Share Posted February 17, 2007 Thanks. But that seems to add a ? to the end of the URL why is that? Ive also noticed that it does not seem to capture #tags or GET variables ?&variable=value. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 17, 2007 Share Posted February 17, 2007 I think $_SERVER['REQUEST_URI']; might work better Add that to your domain and you've got the url. Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 17, 2007 Author Share Posted February 17, 2007 That works better but still does not pick up tags. I was working with this: <script type="text/javascript"> varURL = window.location.href; window.location.href = varURL + "?URL=" + varURL; </script> <?php echo $_GET['URL']; ?> But it does not quite work right. I am quite sure how to tweak it to make it do what i want. -ian Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.