Any way for PHP/CodeIgniter to read the URL, when it's like site.com/#/xyz ...?
Basically I have a mostly Ajax-based site. When you load up a result, it appears via Ajax, and the URL address bar changes from mysite.com
to mysite.com/#xyz/A_Random_Title
.
A_Random_Title
is an SEO-friendly formatted title of the thing loaded up, but the important part is #xyz
. xyz
is the ID of the loaded result and i开发者_开发技巧s used to query the database with.
Is there any way CodeIgniter can read the current URL like that? I don't mean read it once the page has loaded, but read a request to it... hope that makes sense!
Thanks!
Jack
No, it is available to the browser only, so you have to deal it with Javascript. The server can not read it.
Explanation:
Basically the hash component of the page URL (the part following the # sign) is processed by the browser only - the browser never passes it to the server. This sadly is part of the HTML standard and is the same whether or not you are using IE or any other browser (and for that matter PHP or any other server side technology).
Here's what Wikipedia says about it:
The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server. When an agent (such as a Web browser) requests a resource from a Web server, the agent sends the URI to the server, but does not send the fragment. Instead, the agent waits for the server to send the resource, and then the agent processes the resource according to the fragment value. In the most common case, the agent scrolls a Web page down to the anchor element which has an attribute string equal to the fragment value. Other client behaviors are possible
精彩评论