ezekel
(Dixunei)
November 8, 2014, 12:08pm
1
Hi where to put this code in the sitecontroller ?
return [
'components' => [
'urlManager' => [
// here is your normal backend url manager config
],
'urlManagerFrontend' => [
// here is your frontend URL manager config
],
],
];
Thank you in advance
boehsermoe
(Boehsermoe)
November 8, 2014, 1:24pm
2
Nowhere in the controller, this is a configuration for a component(s). Components are part of the application, so you have to place this into the config files!
See here: http://www.yiiframework.com/doc-2.0/guide-concept-configurations.html
ezekel
(Dixunei)
November 8, 2014, 1:38pm
3
can you give me some example how to supply the url to backend and the frontend
Thank you in advance.
boehsermoe
(Boehsermoe)
November 8, 2014, 6:33pm
4
The first UrlManager is used for the running app (frontend, backend or console).
(So you don’t need the “urlManagerFrontend” in the frontend app, only in the backend or console app it makes sense.)
if you want to create a frontend-url in the backend, than you have to place following code into the backend/config/main.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
'urlManagerFrontend' => [
'class' => 'yii\web\urlManager',
'baseUrl' => '/a/frontend/web',
'enablePrettyUrl' => true,
'showScriptName' => false,
],
You can also place it into common/config/main.php, than you can use the twice urlManagers in every app.
ezekel
(Dixunei)
November 8, 2014, 7:03pm
5
boehsermoe:
The first UrlManager is used for the running app (frontend, backend or console).
(So you don’t need the “urlManagerFrontend” in the frontend app, only in the backend or console app it makes sense.)
if you want to create a frontend-url in the backend, than you have to place following code into the backend/config/main.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
'urlManagerFrontend' => [
'class' => 'yii\web\urlManager',
'baseUrl' => '/a/frontend/web',
'enablePrettyUrl' => true,
'showScriptName' => false,
],
You can also place it into common/config/main.php, than you can use the twice urlManagers in every app.
Thank you for the quick reply and for the example,just want to ask in baseUrl =>’/a/ <-is this constant ?
boehsermoe
(Boehsermoe)
November 9, 2014, 9:23am
6
Oh sorry, my mistake i meant ‘baseUrl’ => ‘frontend/web’