2017-01-10 87 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。