我如何获得一个传统的URL结构,单页的应用程序(NO哈希邦)? [英] How do I get a traditional url structure in a single page application (NO hash-bang)?
问题描述
我想建立与angular.js单页的应用程序的唯一的事情就是我想要一个传统的URL结构。
例如:
之前:www.example.com/#/index
后:www.example.com/index 之前:www.example.com/#/user/21345678
后:www.example.com/user/21345678
首先是这可能吗?结果
第二如何将我做到这一点?结果
除了阿帕奇XD任何服务器
您需要启用内角HTML5模式。
的.config(['$ routeProvider','$ locationProvider',函数($ routeProvider,$ locationProvider){
$ locationProvider.html5Mode(真).hash preFIX(!);
然后,你还需要配置您的断绝。看到这篇文章:<一href=\"https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode\"相对=nofollow>配置您的服务器html5Mode
我建议你阅读这篇简短帖子:的 pretty网址角,去除包括hashtag 。在这里面他们也建议设置&LT;基本href =/方式&gt;
HTML的头内
I want to build a single page application with angular.js the only thing is i want a traditional url structure.
Example:
Before: www.example.com/#/index
After: www.example.com/index
Before: www.example.com/#/user/21345678
After: www.example.com/user/21345678
First of all is it possible?
Second how would i do that?
Any server except Apache XD
You need to enable HTML5 mode within angular.
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
Then you also need to configure your sever. See this article: Configure your server to work with html5Mode
I'd suggest reading this short post: Pretty URLs in Angular, Removing the Hashtag. In it they also recommend setting <base href="/">
within the head of your HTML.
这篇关于我如何获得一个传统的URL结构,单页的应用程序(NO哈希邦)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!