AngularJS のみを使用してサブドメインを検出し、それに応じてルーティングすることは可能ですか?
サブドメインSpicy.example.comがexample.comと同じ docRoot を指しているとします。
example.com にはindex.html
居場所があります<div ng-view></div>
私の構成では、パーシャルのルートを定義します。
$routeProvider.when('/food', {templateUrl: 'views/example.com/regular.html'});
しかし、spicey.example.comがパーシャルを独自のものでオーバーライドしたい場合はどうregular.html
でしょうか?
$routeProvider.when('/food', {templateUrl: 'views/spicy.example.com/hot.html'});
Apache/Nginx のようなサーバーで書き換えルールを使用せずにこれは可能ですか?
注:
これは単一のシングル ページ アプリです。
$locationProvider.html5Mode(true);
CORSを使用しています:
$http.defaults.useXDomain = true;