LeoSam
LeoSam

Reputation: 4961

Rewriting URLs with Mod-Rewrite - remove part of URL

I'm serving redirection between mobile and desktop website When a mobile user accesses the site, the URL needs to be modified. Part of the URL should be removed.

Here is the section which needs to be re-written:

/index/home#/web/  /web

Specifically, this part:

/index/home#/web/

Only this part should be affected.

Upvotes: 1

Views: 48

Answers (1)

anubhava
anubhava

Reputation: 786091

As I commented above that this cannot be done entirely on server side as web server only gets part before # i.e. /index/home from your URL of /index/home#/web/. It needs to be handled on client side itself.

You can use this Javascript code to redirect:

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

Upvotes: 1

Related Questions