Jump to content

Getting URL parameter .. not as easy as it seems


lampstax

Recommended Posts

Hey guys,

 

I'm dealing a url that is similar to hxxp://domain/directory/?#{$id}.

 

What I'm trying to do is extract $id from that.  Its not available as a $_GET variable and $_SERVER['REQUEST_URI'] comes up as "/directory/?".

 

Does anyone know how I could retrieve $id ?

 

Thanks

 

 

 

Is this the URL to the page that you are on and you're trying to get it?  If so, then this is a clumsy way of doing it.  The # is causing problems because it's a fragment separator for bookmarks etc in the browser.  What are you hoping to get?

It is the URL of the page that I'm on.  Agreed its not the best URL format but its what the application and I am working with.

 

Its to link directly to a specific part of a page, however, I need to be able to detect what part that is.

 

Any suggestions ?

It is the URL of the page that I'm on.  Agreed its not the best URL format but its what the application and I am working with.

 

Its to link directly to a specific part of a page, however, I need to be able to detect what part that is.

 

Any suggestions ?

 

That fragment is only meaningful to the browser, so if you can't change the format of the URL, then you probably need to look at javascript.

 

Or if you can use mod rewrite on Apache you can rewrite the URL so that the server passes the value to PHP:

 

/?#1 becomes: /?id=1#1 for example.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.