How remove/hide web folder in Yii2 basic project


I have a problem. :unsure: How remove/hide “web” folder in Yii2 basic project? I am accessing the following: /basic/web/site/about but would like to access as follows: /basic/site/about without the web folder.

Is it possible? I’ve tried .htaccess and couldn’t.

There should not normally be any html files under web, they should be under the views folder. This way, when you access your site, you use controller/view or in your case site/about.

Maybe you have got confused with MVC urls vs normal direct linked urls.

I did not . By default, when I installed a new application via basic composer he automatically generated web folder, inside two folders and a index.php. When will I access via browser, to access my application, I always have to access the web folder in front of the controller/action. Getting as follows: web/controller/action would remove this folder or hide, to access the following controller/action way.

You should point your web root to the web folder. This way, you get (or you can remove the index.php with htaccess if you just want

If you really want to have the word “basic” as part of your url, don’t map it to the web folder called basic, just rewrite basic/index.php to index.php in htaccess and you can achieve or by also removing the index.php in htaccess.

I think the question is not correct.

The point is that you can not delete that folder, but what you want is to omit the ‘web’ word from the url.

This could be done with UrlManager, dig in there for more information, it will help you to define/construct frendly urls.