Welcome Guest, Not a member yet? Register   Sign In
# Character in the url
#1

[eluser]Typeslowly[/eluser]
Hi,

I want to format urls for a flash app with #.

An example url

website.com/#/segment/segment/segment/

When I use the url helper to get the segments Codeigniter ignores everything after the #. Any idea how I can read these segments?


Many thanks.
#2

[eluser]WanWizard[/eluser]
The # is a reserved symbol in a URI scheme: http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax

If you want to use it, you will have to escape it, to "#" instead of "#".
#3

[eluser]Typeslowly[/eluser]
So is it possible to grab the segments using $this->uri->segment(n) when using this type of url mysite/#/segment/segment/segment/ ?

Thanks.
#4

[eluser]WanWizard[/eluser]
No, the '#' is reserved in a URI.

Ah, wait. Stupid forum software is ff-ing up my post.

Maybe as code:
Code:
your URI should be mysite/#/segment/segment/segment

Arrghhh... That doesn't work either. Replace the '#' with a procent sign, followed by the number 23.
#5

[eluser]Typeslowly[/eluser]
Swfaddress] utilises # to communicate between swf's, javascript to set the url and title of a web page. I understand that # is used for deep linking within the html page and that it is reserved for this purpose.

Is it not possible to get CI to someway use $this->uri->segment(n) if the url includes #.
#6

[eluser]WanWizard[/eluser]
The short answer is no, the URL is parsed by the webserver before it reaches your application.

Having said that, there are some things I can think of:
- use something that is not reserved by standards, and stick to an RFC standard URI.
- dump $_SERVER, and see if there's a variable that contains what you want (means you have to parse it yourself).
- use a rewrite rule to rewrite /#/ to for example /~/, which will get to CI as a segment.
#7

[eluser]Typeslowly[/eluser]
Hi WanWizard,

Thanks for your input so far, it is very much appreciated.

I am gonna junk the use of php codeigniter for reading the url and use JS instead. Do you know why you can grab the URL with JS using document.location but it is not possible to do something similar with PHP when using # as a segment?

Thanks.
#8

[eluser]WanWizard[/eluser]
Because the # in the URL has meaning client-side, but not server side.

The browser already strips the anchor bit when it sends the HTTP request to the server, so the server will never see it. You can test this by adding an anchor (#somthing) to any URL in the browsers URL bar, and press enter. The browser won't request the page, as it is already loaded.




Theme © iAndrew 2016 - Forum software by © MyBB