how to set URL (admin instead of backend/web) in yii2 advanced application

I am facing a grate problem in my project. When i browse url with my project name than it’s show folders, but i don’t want to show those folder i want to show direct my web site, like ‘localhost/mywebsite/admin’.

I also try to solve this problem to add my backend/config/main.php file

‘urlManager’ => [

‘class’ => ‘yii\web\UrlManager’,

‘enablePrettyUrl’ => true,

‘showScriptName’ => ‘false’

],

but it does not work. Please help me to solve this problem.

I’d say you can’t really solve this by changing the configuration of your Yii application. If you see files with the title “Index of…” it means that your web root is pointed to the application root.

This is about the configuration of your server. There is a chapter in the guide regarding this topic:

http://www.yiiframework.com/doc-2.0/guide-start-installation.html#configuring-web-servers

Do you have a web hosting where you can manage the web root (or dedicated server where the config is up to you)?

Perhaps the support of your web hosting can solve this for you if you tell them where do you want to set web root of your domain.

You can have for example .../your_application/advanced/frontend/web/ pointed to www.yourdomain.com and .../your_application/advanced/backend/web/ pointed to admin.yourdomain.com.

Thanks for your compliment.

I think i have found the solution from your compliment.

For others who come across this thread, the solution can be found by following the set up outlined here if you are on shared hosting, and cannot have multiple web roots.

http://www.yiiframew…ed-hosting.html

That’s a good point. I wasn’t even aware of this guide.