URL rewriting - hash removal

How to remove a hash sign (#) from a page URL? I am using the SWFAddress (jQuery) plugin for deep links.

I need to replace this

local / website / blog #

by

local / website / blog

(Yes, #blog is just a binding).

Somehow rewriting urls in .htaccess doesn't work

RewriteRule / blog #blog [L]

Any suggestions?

+3
source share
2 answers

The hash bit in the URL is not sent to the server when the page is requested, so you cannot use such redirection rules. This is only the client side.

+11
source

URL- , . Heres one JavaScript:

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

, URL URL # /. , /site/#blog /site/blog.

+10

Source: https://habr.com/ru/post/1727094/


All Articles