URL rewriting - removing hash

How can I remove the hash sign (#) from the page's URL ? I am using the SWFAddress plugin (jQuery) for deep linking purposes.

I need to replace this

localhost/site/#blog

by

localhost/site/blog

(Yes, #blog is just an anchor).

Somehow url rewriting in .htaccess doesn't work

RewriteRule /blog #blog [L]

Any suggestions ?

Answers


The bit with the hash in the URL is not sent to the server when requesting a page, so you can't use redirect rules like that. It's client-side only.


As the URL fragment is not transmitted to the server, you can only use a client side solution. Here’s one using JavaScript:

if (location.href.indexOf("#") > -1) {
    location.assign(location.href.replace(/\/?#/, "/"));
}

This simply checks if there is a # in the URL and replaces the first occurrence with /. So /site/#blog would get /site/blog.


Need Your Help

How do I make a simple DNS server listening two ports simultaneously in python

python dns ports listen

I'm trying to build a DNS server in python. It must listen two ports (8007 - client, 8008 - admin). The client only send an URL and receives the respective IP. The admin has permissions to change t...

How do I stop my switch statement from outputting the case in Matlab

matlab function

I am trying to write a function that can accomplish 3 tasks by using the menu statement in Matlab, But for some reason it keeps outputting the case number with my function answer.