views:

78

answers:

4

Hello,

Recently when i saw google results page, the query and other parameters where passed with # (hash) instead of the usual "?"

Also, in facebook i saw the same thing. This was quite interesting and after a simple search with google, i found the results related to perl and Ruby but no result with PHP.

Is it possible to pass parameters with # in PHP instead of "?" or is this possible only with perl/Ruby. This will be useful and search engines will not parse the parameters in the URLs.

Any ideas will be helpful to me.

+1  A: 

Nope, it is not possible.
What have you seen is just a decoration, to reflect an AJAX call in the address bar.

No matter what language you choose - all of them sits on the server side and communicate with browser using HTTP protocol. And no anchor allowed in HTTP requests. That's completely client side thing

Col. Shrapnel
It's not possible _without_ clientside scripts passing the variables to serverside. You can easily set something up to make javascript hit the server with the hash data
Jamie Wong
@Jamie it is not possible with HTTP protocol. Period
Col. Shrapnel
It doesn't get sent over the HTTP protocol when you hit a page, I can agree with that. But Javascript can extract that data, serialize, then hit a serverside scripts with an AJAX call or with a redirect as GET variables.
Jamie Wong
+6  A: 

Traditionally, the # told the browser to automatically scroll to a particular point in the page, which was (and still is) often used to implement links from one part of a page (e.g. a table of contents) to another (e.g. a section heading).

However, it also has the effect of causing the URL containing the # to be recorded in the history, even if it's identical to the previous URL except for the # and what follows it. (In other words, the user is still on the same page.) This means that the back button can be used to get back to the state that you were previously in, even if that state-change doesn't correspond to a page-load.

Modern AJAX applications therefore often use it to signify that something has happened that the user might want to "go back" from.

David
If I understand this correctly, it is really only a signal. Using the back button will not actually undo the changes to the page.
Ryan Kinal
@david any tutorial you referred in getting the value of the parameter as in google (hash style) using ajax?
Aakash Chakravarthy
@Aakash Chakaravarthy: Just used a Wikipedia article (http://en.wikipedia.org/wiki/Fragment_identifier) and personal experience. There are ways to get the value of the fragment identifier (`window.location` if I remember correctly, but I'm not up-to-date on the current best practices for AJAX).
David
@Ryan Kinal: I believe that's correct, but you should be able to programmatically undo the changes when the back button is pressed. See Gmail for an example of this working.
David
A: 
daotoad
A: 

there probably is some server rewriting or so. Example with apache server, you can handle some uri like

http://www.mysite.com#something

and rewrite it as

http://www.mysite.com/perl/script.pl?data=something

and so process it as a simple GET query to your script.pl

This is all server-side processing, un-visible to the client

benzebuth
it cannot be server processing because fragment is not being sent to the server.
Col. Shrapnel
not sent to server ? well maybe i misunderstood something, but how do you submit a request to google without sending anything to a server ...oO
benzebuth