也许这很简单,但这是我第一次使用angular-ui-router。我使用的是html5模式,并且我配置了以下状态:
$locationProvider.html5Mode(true);
$authProvider.loginUrl = API_LOCATION + 'authenticate';
$urlRouterProvider.otherwise('/auth');
$stateProvider
.state('auth', {
url: '/auth',
templateUrl: TEMPLATES_LOCATION + 'login.html',
controller: 'AuthController as auth'
})
.state('country', {
url: '/country',
templateUrl: TEMPLATES_LOCATION + 'country.index.html',
controller: 'CountryListController'
})
.state('country.select', {
url: '/select',
templateUrl: TEMPLATES_LOCATION + 'country.select.html',
controller: 'CountrySelectController'
})
.state('country.edit', {
url: '/:isoCode',
templateUrl: TEMPLATES_LOCATION + 'country.edit.html',
controller: 'CountryEditController'
});
所有国家/地区路线都会加载country.index.html
和CountryEditController
。为什么呢?
我的.htaccess文件(角度应用程序位于名为&#34的子文件夹中; admin")
RewriteEngine on
#RewriteBase /admin/ <- tried this too
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /admin/index.html [NC,L]