Forum Moderators: coopster

Message Too Old, No Replies

get currentl url via php?

         

jake66

3:34 am on Jan 9, 2006 (gmt 0)

10+ Year Member



i use htaccess to rewrite my query-stringed url's into /category/page.html, etc.

so doing a simple PHP_SELF call will produce only the filename and not the *actual* url.

i would like to display whatever the url is, that the user currently has in their address bar (less any possible session id's that may be peeking around)

is this possible via php?

coopster

3:24 pm on Jan 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The $_SERVER superglobal is a good place to start. Try dumping that to your screen and you will be able to see what is available. I'm guessing if your browser's address bar says, "http://example.com/category/page.html", then $_SERVER['REQUEST_URI'] will contain the same.

jake66

12:22 am on Jan 11, 2006 (gmt 0)

10+ Year Member



thank you!
$_SERVER['REQUEST_URI'] did the trick :)

coopster

3:27 pm on Jan 11, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure, and don't forget that variable is user-supplied input, so you may need to scrub it before using it, depending on how you use it. strip_tags() [php.net] is one edit that comes to mind ...