I would like to have my site visitors go to a specific subdomain based on routeParams
for example if they go to " http://example.com/foo " they will be redirected to " http://foo.example.com "
Can I do that using the routeProvider with something like:
$routeProvider
.when('/:my_affiliate', {
redirectTo: function(routeParams){
return 'http://' + routeParams.my_affiliate + '.example.com';
},
})
;
You can do this with routeProvider
how you state. If you want to redirect a user to a different subdomain use window.location
with the desired URL. However, consider this will take you of your application. This may however be what you were expecting :D
$routeProvider
.when('/:my_affiliate', {
redirectTo: function(routeParams) {
window.location = 'http://' + routeParams.my_affiliate + '.example.com';
}
});
Hope that helps you out!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.