Getting in common folder after hide frontend/web

Good day everyone!

I upload images via backend to common/img folder.

I placed .htaccess in root directory to hide "frontend/web" from Url.


Options -Indexes

RewriteEngine on

RewriteCond %{HTTP_HOST} ^$ [NC,OR]

RewriteCond %{HTTP_HOST} ^$

RewriteCond %{REQUEST_URI} !frontend/web/

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

After doing so, my frontend couldn’t get images from common folder.

Any idea how to get them?

Thank you

I would suggest you should move the images to a public folder

I will give it a try.

Thanks for your suggestion.

Public folder means folder that out of Yii app? Something like ""?

My root directory is, how do I go to public folder?

If I type,

it will tell me “ not found”. :(

In the first place, you should learn what ‘DocumentRoot’ means, and what the difference between URLs and file paths is.

Your DocumentRoot for the front-end app is probably ‘/some-dir/some-sub-dir/yii2/frontend/web’. This directory serves as the base URL for the front-end app that is ‘’.

And your DocumentRoot for the back-end app is ‘/some-dir/some-sub-dir/yii2/backend/web’. This directory serves as the base URL for the back-end app that is ‘’.

Now, if you want the users of your front-end app to access the uploaded images, you have to place them in a URL under ‘’, e.g. ‘’ which corresponds to a path of ‘/some-dir/some-sub-dir/yii2/frontend/web/public/img’.

Note that the directory ‘/some-dir/some-sub-dir/yii2/common/img’ can not be represented as a valid URL for the front-end app, because it is not under the DocumentRoot of the front-end app.

And also note that the directory ‘/some-dir/some-sub-dir/yii2/frontend/web/public/img’ can be accessed from the server-side PHP of your back-end app, while the URL ‘’ might not be accessed from the users of the back-end app. So you can store the uploaded files in the directory that can be accessed from the front-end app users.

as @softark explained it in more details, basically to sum it you need to have your upload under app/web folder.

you can create a separate virtual host to serve the static files which I would not recommend because it is likely you will get it wrong.

Thank you so much for replies.

I will see what I can do ;)