0

I have a website with a database of part numbers. My manager wants to be able to type:

www.site.com/products/part#

and have thepage automatically take you to the relevant page.

Right now I have it take the URL and mod-rewrite the page to:

www.site.com/search.php?sku=xxxx

And a php srcript will $_GET the sku and do the search, problem is, some part numbers have # and / symbols in them, eg:

www.site.com/products/VS816UT#ABA

I can get around any slashes with mod-rewrite, but the browsers strips the # symbol before the $_GET can see it.

Is there a way around that?

5
  • no way around it. it's how <a name="ABA"> works on a web page. it's completely and only in the browser. There may be an advanced javascript way to do it, but the bottom line is, for what you're asking it just doesn't seem worth the effort.
    – Tim G
    Dec 2, 2011 at 20:47
  • @TimG: I think you mean <a id="ABA"> ;)
    – Blender
    Dec 2, 2011 at 20:53
  • @TimG: Look at the source code of this page. Only id works with the hash marks. name produces nothing.
    – Blender
    Dec 2, 2011 at 20:56
  • i've never seen someone using ID to scroll in a document. not suggesting it's bad - just haven't seen it. it's interesting. using anchor tags with name does work and has since the early 90's. :)
    – Tim G
    Dec 2, 2011 at 21:02
  • That's odd. I've never had name work for me...
    – Blender
    Dec 5, 2011 at 17:28

3 Answers 3

3

Anything past the hash (the #) isn't sent to the webserver.

If you want to get around this, why not append the #ABA with a slash:

www.site.com/products/VS816UT/ABA

And use mod_rewrite to properly map it to your PHP file.

1

the # symbol is reserved for anchor tags inside browsers, in accordance with web standards.

0

There should be no trouble doing it, but what you want is a handler for /products/ that gets the trailing part of the url (frameworks like codeigniter are good at that).

You need a single page handler that dispatches based on as much (or as little) of the url as you need.

Unfortunately, at least some browsers strip the # and everything after it. I did a test using a url with a# and monitored what the browser sent with tcpdump and got this:

Url:

http://127.0.0.1/onepage/products/zss#www?b=A#B

tcpdump o/p:

GET /onepage/products/zss

Presumably, server-to-server is the only way this can work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.