How to get page url?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

How to get page url?

Post by rei27 »

Hello,

I need to get the page url, e.g.
http://www.sekataplus.com/product_detai ... 0864fad1d7

I am using 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], but it just capture the http://www.sekataplus.com.

How can i solve this?
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

Re: How to get page url?

Post by SvanteH »

That works fine by me when testing. REQUEST_URI returns the GET request so that should be it. Do you have any more code snippet on which page you're trying to capture it from etc.
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

Re: How to get page url?

Post by rei27 »

SvanteH wrote:That works fine by me when testing. REQUEST_URI returns the GET request so that should be it. Do you have any more code snippet on which page you're trying to capture it from etc.
The code works fine when i am in localhost, but when i put it into live server, it just can capture the server.
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

Re: How to get page url?

Post by SvanteH »

What exactly are you trying to use this for?
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

Re: How to get page url?

Post by rei27 »

SvanteH wrote:What exactly are you trying to use this for?

I need capture the url and store it into database in order to record the visitor hit for this page!
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

Re: How to get page url?

Post by SvanteH »

Sounds very odd if your production server fails to put any values into $_SERVER["REQUEST_URI"] to be honest.
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

Re: How to get page url?

Post by rei27 »

SvanteH wrote:Sounds very odd if your production server fails to put any values into $_SERVER["REQUEST_URI"] to be honest.

Thanks a lot, i got the solution. I just put $_SERVER['QUERY_STRING']
Post Reply