Change web folder destination

I created some projects with yii 1 and I decided to learn yii2 to go for the next step.

So I have this basic question.

Can I copy and paste the files of the web directory at the root directory of my server, making the changes at the index.php?

For now I created a .htaccess file at root directory as bellow but then the urls show the "web" folder.It is supposed to be ok at the production server?


Options -Indexes

RewriteEngine on

RewriteRule ^(.*)$ web/$1 [L]

.htaccess of "web" folder

# use mod_rewrite for pretty URL support

    RewriteEngine on

    # If a directory or a file exists, use the request directly

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    # Otherwise forward the request to index.php

    RewriteRule . index.php

    # ...other settings...

I found this about my question.

yii2 .htaccess

The Yii framework itself is in your ‘/vendor’ directory. What you are actually working with is a put together system/app for interacting with the framework. All the basic and advanced templates are, are just starting point ideas. You could choose to not use either, and make your own. So yes, you can organize and move them however you want. You will need to fix the paths that it may break :)

You could create a symlink or change the document root to point to the /web directory.

If the links on your site are still being generated with “/web” in them, then try changing the ‘request’ baseUrl and ‘urlManager’ baseUrl params in your config. The htaccess method takes care of removing the web directory for Apache, but Yii was still adding /web on UrlManager generated links.