Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide #! on browser address bar?

Let's say I have the following link:

www.blahblah.com/#!?page=index

How can I convert it to one of the following:

  • www.blahblah.com/#!/index (this one should be made with mod_rewrite)
  • www.blahblah.com/ajax/index (still mod_rewrite, but #! replaced with ajax)
  • www.blahblah.com/index (the page will load with AJAX like facebook, but #! will be hidden)

Can anyone give me examples of each of the questions above?

Thanks alot!

like image 513
Aristona Avatar asked Dec 01 '11 00:12

Aristona


People also ask

Can I Hide apps on my phone?

Use built-in settings to hide apps on Android First, open Settings, tap Home screen, and scroll to Hide apps. Tap the apps you want to hide, and they'll move to the Hidden apps section.


2 Answers

Anything after the hash (#) isn't sent to the server, so you cannot read it server-side. You can, however, redirect the user using JavaScript. The information you're looking for will be stored in the variable window.location.hash.

On page load, you can do something like the following:

hashString = window.location.hash.substring(8);
window.location = 'http://www.blahblah.com/'+hashString;

We're using substring to remove the first eight characters (#!?page=), so we'll be left with index.

like image 73
kba Avatar answered Sep 25 '22 17:09

kba


Module rewrite only changes what the server sees. Module rewrite can't, change what the local browser sees, which is where the js is being run.

The way Facebook load, is through requesting the contents of the new page, then it updates the window URL instead of having to re-load everything. This is done, so If an item needs to be shared or linked the link is all up to date with what they're actually viewing, so when the page gets a fresh re-load, the browser loads the actual full php page, requested from the server.

like image 27
nickw444 Avatar answered Sep 23 '22 17:09

nickw444