Take the 2-minute tour ×

I have this software from another programmer who has left the project. Now I have a problem, some of the URLs with GET variables wont work i think it's because of the # so this URL looks like this.


so as you can see the GET variable only parses 'myvariable-' so the #2 is cutted off. I need to have the full 'myvariable-#2'

I have searched google and spent hours to get this resolved. Please help me. Thank you!


So I found a solution in doing this. I parse the whole URL using javascript, and from there I can now get the remaining string after the #

Thank you for all the answers. Thanks a lot!

share|improve this question

migrated from programmers.stackexchange.com Oct 14 '13 at 11:35


...thats not a get variable, its part of the url. Cant you break the requested url up by its components? –  GrandmasterB Oct 14 '13 at 2:51
That's not an URL. It's missing the scheme, a mandatory part of URL. –  Jan Hudec Oct 14 '13 at 7:36
If answers have helped you, then please select one as 'Solution'. –  user338195 Oct 14 '13 at 10:47

3 Answers 3

The # starts a fragment identifier. Fragments are handled client-side, that part of the URI isn't even sent to the server in the first place, so you simply cannot handle it there.

share|improve this answer
you mean there will be no work arounds on this matter? –  Vinmark Benedicto Oct 14 '13 at 2:54
@VinmarkBenedicto Can you not use a '#' in the URI? –  MichaelT Oct 14 '13 at 3:04
@MichaelT it is another programmer's software. and he left. I am hired to continue what he is doing, unfortunately this is one of his mistakes. –  Vinmark Benedicto Oct 14 '13 at 3:29
Jörg is right. Please read this from Alan Skorkin –  Marcel Oct 14 '13 at 6:15
@VinmarkBenedicto: You can pass any character in URL by properly escaping it. In PHP escaping is done using urlencode. PHP will automatically decode parameter values for you, but IIRC you have to decode path yourself (using urldecode). –  Jan Hudec Oct 14 '13 at 7:38

There is no way to get the fragment (#...) from PHP. It seems as if there is a way to do that with javascript. See Parsing URL hash/fragment identifier with JavaScript

Just in case you're on a Unix box: you can run nc (netcat) from a terminal window like this:

$ nc -l 8080

which opens a reading connection on port 8080. Now you can connect a browser on this machine to that port and request a URL, such as http://localhost:8080/foobar/baz.html#abcde. The output of netcat identifies the URL the server sees:

GET /foobar/baz.html HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Accept-Encoding: gzip,deflate,sdch

So the requested path is /foobar/baz.html without the fragment identifier (#abcde).

share|improve this answer
And if you're on Windows, you can examine the contents of HTTP requests using tools such as Fiddler or Charles. –  Carson63000 Oct 14 '13 at 6:39

As pointed out by others, in URLs # is the separator for the fragment identifier.

If a # character is included in the path, then it must be properly encoded: www.domain.com/myvariable1/myvariable-%232.

This way, the path as seen by the server will be myvariable1/myvariable-#2.

share|improve this answer

Your Answer


