2
我想使用$ locationProvider.html5Mode(true)删除angularJs中的#哈希值;但是这导致所有的URL都通过angularJs被路由。我如何设置它,以便只有一些预定义的URL通过angularJs路由,而其余的仍然使用Laravel。AngularJs + Laravel Routing
的代码是:
app.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/alls', {
templateUrl: app.site_url + 'ang/index',
controller: 'MainCtrl'
})
.when('/alls/page/:page', {
templateUrl: app.site_url + 'ang/index',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/alls'
});
$locationProvider.html5Mode(true);
}
]);
所以,如果它不是/承滴盘或/承滴盘/页/,Laravel应该处理路由。
你使用任何服务器端重写? – DaGardner
@Christian:是的,其他网址应该通过index.php。我使用htaccess重写:'RewriteCond%{REQUEST_FILENAME} -s [OR] RewriteCond%{REQUEST_FILENAME} -l [OR] RewriteCond%{REQUEST_FILENAME} -d RewriteRule ^。* $ - [NC,L] RewriteRule ^。* $ index.php?/ $ 1 [NC,L]' –
以及您从哪里为前端服务?从/公共目录? – DaGardner