admin管理员组文章数量:1327843
I would like to have my site visitors go to a specific subdomain based on routeParams
for example if they go to "" they will be redirected to ""
Can I do that using the routeProvider with something like:
$routeProvider
.when('/:my_affiliate', {
redirectTo: function(routeParams){
return 'http://' + routeParams.my_affiliate + '.example';
},
})
;
I would like to have my site visitors go to a specific subdomain based on routeParams
for example if they go to "http://example./foo" they will be redirected to "http://foo.example."
Can I do that using the routeProvider with something like:
$routeProvider
.when('/:my_affiliate', {
redirectTo: function(routeParams){
return 'http://' + routeParams.my_affiliate + '.example.';
},
})
;
Share
Improve this question
asked Aug 27, 2015 at 21:14
Jared WhippleJared Whipple
1,1714 gold badges17 silver badges40 bronze badges
1 Answer
Reset to default 7You 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.';
}
});
Hope that helps you out!
本文标签: javascripthow do I redirect to external URL using angularjs routeProviderStack Overflow
版权声明:本文标题:javascript - how do I redirect to external URL using angularjs routeProvider - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742219478a2435181.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论