Capturing hash(#) from URL in CodeIgniter

2019-07-15 13:10发布

问题:

I have a url that looks like

mysite.com/transactions/view/123456

which works fine.

however my client now wishes to have a hashbang in the url

mysite.com/transactions/view/#123456

Now the obvious issue here is that browsers treat the hashbang as an anchor directive.

Is there anyway to in code igniter allow the hashbang and have #123456 (or even just 123456) passed to the view function?

回答1:

Is there anyway to in code igniter allow the hashbang and have #123456 (or even just 123456) passed to the view function?

Short of javascript, no. The browser simply doesn't send the 'fragment' portion of the URL to the server. PHP can only read it if javascript running after the page has rendered sends it in a second request.