Symfony2を使っています。今の環境には hoge.example.com というサブドメインがあり、
routing.ymlでホスト名でのマッチング機能を使っています。
以下のように記載しています。
lang
1example_hoge: 2 resource: "@MyHogeBundle/Controller/" 3 type: annotation 4 prefix: / 5 host: "hoge.example.com" 6 7example_fuga: 8 resource: "@MyFugaBundle/Controller/" 9 type: annotation 10 prefix: /
マッチングは問題なく機能していますが、
以下のようにドメインとサブドメインを使い分けようとするとうまくいきませんでした
lang
1<pre>hoge_index: {{ url('hoge_index') }}</pre> 2<pre>hoge_test: {{ path('hoge_test') }}</pre> 3<pre>fuga_index: {{ url('fuga_index') }}</pre> 4<pre>fuga_test: {{ url('fuga_test') }}</pre>
上記のコードをMyFugaBundleのindex.html.twigから走らせると、下のようになります
ルート:example.comの場合
lang
1hoge_index: http://hoge.example.com/app_dev.php/ 2hoge_test: //hoge.example.com/app_dev.php/test 3fuga_index: http://example.com/app_dev.php/ 4fuga_test: http://example.com/app_dev.php/test
ルート:hoge.example.comの場合
lang
1hoge_index: http://hoge.example.com/app_dev.php/ 2hoge_test: /app_dev.php/test 3fuga_index: http://hoge.example.com/app_dev.php/ 4fuga_test: http://hoge.example.com/app_dev.php/test
example.comの場合に、サブドメインからURLが生成されてしまっています。
どこか設定を間違えているのでしょうか
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。