-2

I have a single page site. My page has multi section. I define sections with #. for example detail section has a url like http://bamap.ir/#/details.

I want to rout some urls as follow:

  • http://bamap.ir/details go to http://bamap.ir/#/details
  • http://bamap.ir/user-authentication go to http://bamap.ir/#/user-authentication
  • ...

How can I rout this urls with .htacccess?

Morteza Malvandi
  • 1,656
  • 7
  • 30
  • 73

2 Answers2

0

I think you should look at the History API that HTML5 provides: https://www.w3.org/TR/html5/browsers.html#the-history-interface

Tfunction removeHash () { 
    var scrollV, scrollH, loc = window.location;
    if ("pushState" in history)
        history.pushState("", document.title, loc.pathname + loc.search);
    else {
        // Prevent scrolling by storing the page's current scroll offset
        scrollV = document.body.scrollTop;
        scrollH = document.body.scrollLeft;

        loc.hash = "";

        // Restore the scroll offset, should be flicker free
        document.body.scrollTop = scrollV;
        document.body.scrollLeft = scrollH;
    }
}

quoting the answer here

Community
  • 1
  • 1
Karan Shah
  • 1,304
  • 11
  • 15
0

Rewriting to fregment is imposible as # is not sent to the server. However you could redirect any uri to fregment using the R flag.

RewriteEngine on
RewriteRule ^detail/?$ /#/detail [NE,R]

This will redirect you to /#/detail if you go to /detail .

Amit Verma
  • 40,709
  • 21
  • 93
  • 115