0

How can I get the string comes after # sign the URL by using CodeIgniter?

example:

http://site.com/controller/function/#bla-bla
Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
T4mer
  • 430
  • 2
  • 7
  • 22

1 Answers1

3

You can't get the URL hash via PHP or CI.

This belongs to client-side, you should use JavaScript to achieve this:

var hash = window.location.hash;
console.log(hash); // "#bla-bla"

And you can remove the # character by substr(1):

console.log(hash.substr(1)); // "bla-bla"
Community
  • 1
  • 1
Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
  • This is the correct answer, handle the hash on the frontend(browser level). This is pretty pointless, but might work in your routes: $route['controller/function/(\#\w.+)'] = 'controller/function/$1'; – Philip Aug 15 '13 at 11:29
  • I think the browser doesn't send `GET` requests with `fragment` parts to the server. – Hashem Qolami Aug 15 '13 at 11:31
  • You are correct. I'm baffled why the OP would want to send the hash tag. I think maybe he is trying to load content on a per div basis, in which case his going the wrong way about it – Philip Aug 15 '13 at 11:40