Learn How To Get Current Full URL From Address Bar Show Complete Browser


Learn How To Get Current Full URL From Address Bar Show Complete Browser
  Forums Index
      » PHP Forums
        » » Learn How To Get Current Full URL From Address Bar Show Complete Browser



Learn How To Get Current Full URL From Address Bar Show Complete Browser
Post Description:
Post Tags: learn, how, to, get, current, full, url, from, address, bar, show, complete, browser, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 1856 Times Since Wed Apr 11, 2007 6:15 pm Posted By hostman with 2 replies
Learn How To Get Current Full URL From Address Bar Show Complete Browser
so today i was writing a php script and i wanted to asign a varialble which was equals to the current url on my browser.

I'm wondering if it's possible to have my PHP get the entire URL from the address bar.

Well you can, using $_SERVER['PHP_SELF']
like this:

     Code:
<?php
echo $_SERVER['PHP_SELF'];
?>


thats ok, but how about if you are mascarading your urls with apache mod rewrite. because whe you do $_SERVER['PHP_SELF'] it will show the complete url but it shows the php file and not my mod_rewrite url.

so if you are wondering if you can get the full url when its masacareded with mod_rewrite, i think that answer would be no. The .htaccess file executed mod_rewrite independantly of php and before the php code is parsed.

Your best bet is to write your code so it will from your rewrite rule. Since you know what the rule is doing, write something like a function to match your rewrite rule in your .htaccess file.

for example, if i were mascarading this url


     Code:
http://www.wallpaperama.com/forums/learn-how-to-get-current-full-url-from-address-bar-show-complete-browser-t1051.html


i wouln't be able to get it with php, but i think you could get it with javascript very easy. now i just have to figure out how to get it from javascript to php.. but that's another post.

Unless someone knows how to do this, i would like to know how you can get it. please help if you do by replying to this post.

Leave Your Comments
* Your Name

  * Your Email Address (Will Not Be Published)

* Your Comments


Add Picture To Comments
Yes No             upload
Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

     




Comments and replies About Learn How To Get Current Full URL From Address Bar Show Complete Browser






:: 1 :: #30477 - Reply By Trinhntt On Mon Dec 03, 2007 10:38 pm
1.

2.
$host = $_server['http_host'];
3.
$self = $_server['php_self'];
4.
$query = !empty($_server['query_string']) ? $_server['query_string'] : null;
5.
$url = !empty($query) ? " $host$self?$query" : " $host$self";
6.

7.
echo $url;
:: 2 :: #45151 - Reply By deepak On Wed Mar 12, 2008 6:50 am
very useful information. am i the only one