2017-01-10 85 views
-2

我有一个单页面网站。我的页面有多个部分。我定义了与#的部分。例如detail部分的网址类似于http://bamap.ir/#/details如何在.htaccess中重写网址

我想击溃一些网址如下:

  • http://bamap.ir/detailshttp://bamap.ir/#/details
  • http://bamap.ir/user-authenticationhttp://bamap.ir/#/user-authentication
  • ...

我怎么能击溃这个网址.htacccess

+0

[从AngularJS网址(#符号)中删除片段标识符](http://stackoverflow.com/questions/14771091/removing-the-fragment-identifier-from-angularjs-urls-symbol) –

+0

I没有使用angularjs。 –

+0

然后你在用什么?我想你应该详细说明你的问题 –

回答

0

我想你应该看看历史的API,HTML5提供: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; 
    } 
} 

引用答案here

0

重写fregment是IMPOSIBLE为#不会被发送到服务器。但是,您可以使用R标志将任何uri重定向到fregment。

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

如果您转到/ detail,这会将您重定向到/#/ detail。