Reputation: 2139
As you know in MVC.NET we have areas which give ability of separating admin part with user part. In application folder indexing is like below:
/Areas
/Admin
/Controllers
/Models
/Views
/Controllers
/Models
/Views
Above style shows that we have different folders for controllers, Models and Views .
Url for parts which are sub folder of an area are like this
domain.pre/area/controller/action
and url for parts which are not sub folder of an area are like this domain.pre/controller/action
know in yii2 we do not have areas. My question is that If we have two controller like A
and B
can we define a different url for one of them?
For example route of A
controller be like this domain.pre/A/index
and route of B
controller be like this domain.pre/admin/B/index
Thank you for your time and response
Edit
I have 4 controller named Word
, Panel
, Regex
and Language
if I want to access to the index action of each controller I should follow this rule:
mysite/panel/index
mysite/word/index
mysite/regex/index
mysite/language/index
know i want change urls to these formats:
mysite/panel/index
mysite/admin/word/index
mysite/admin/regex/index
mysite/admin/language/index
Upvotes: 1
Views: 896
Reputation: 151
Based on the url format that you want to achieve,
mysite/panel/index
mysite/admin/word/index
mysite/admin/regex/index
mysite/admin/language/index
You have to include UrlManager configuration like below.
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName'=>false
]
If you do not add this in your config file, you can only access your website's pages this way.
mysite/index.php?r=panel/index
mysite/index.php?r=admin/word/index
Upvotes: 1