问题
I want to give the users on my portal to have their domains mapped to their page and internal pages from their on.
So, the user site url http://www.username.com should map to http://example.com/userid, similarly all the links inside should also map. Like, http://www.user-id.com/page1 => http://example.com/userid/page1 http://www.user-id.com/section1/page1 => http://example.com/userid/section1/page1
Has some body done this in angular js? I am using angular 1.3 and open to move to 1.4 or 1.5
回答1:
Here is an example router setup with ui-router that could match what you are attempting:
// APPLICATION ROUTES
// -----------------------------------
// For any unmatched url, redirect to /app/
$urlRouterProvider.otherwise("/login/signin");
//
// Set up the states
$stateProvider.state('app', {
url: "/app",
templateUrl: "views/app.html",
resolve: loadSequence('any library you want'),
abstract: true
}).state('app.page1', {
url: "/page1",
templateUrl: "views/page1.html",
resolve: loadSequence('any library you want'),
title: 'Dashboard'
}).state('app.page1.section1', {
url: '/page2',
template: '<div ui-view class="fade-in-up"></div>',
title: 'Page 2',
});
来源:https://stackoverflow.com/questions/36085246/angular-js-custom-domain-mapping