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
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: learn how to get current full url from address bar show complete browser
POST# 389
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: 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.


Mon Dec 03, 2007 10:38 pm
1
Trinhntt
Reply #991
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;
Wed Mar 12, 2008 6:50 am
2
deepak
Reply #992
this is pathetic, u just look at the designing colors u have used. useless, shameless guy. change the design

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload