Hosting multiple applications using single yii2 on shared hosting

Hi Team,

I am using yii2 framework with 4 internal applications like frontend,backend etc…Now i am trying to move the framework core and applications out of my web root by following the below url

We are using the same sessions for all the internal applications.My present app structure is


Now, i want to move all these application out of my webroot like


---------./frontend-web/ --> content of web folder of frontend app
---------/backend-web/ --> content of web folder of backend app


Please suggest me how can i do this correctly as my current attempts in .htaccess and config files are not successful till date

Are you able to include files from outside of webroot?

Yes.I am able to include php files that reside outside webroot and inside my user account.


I kept all my files in /home/username/

Yes, your structure seems OK. You need to fix paths in your index.php but other than that it should work just fine.

Still not working. Any configuration required in specific app’s config/main.php file? My present config settings are like this in frontend/config/main.php.

‘request’ => [
‘web’ => ‘/frontend-web’,
‘adminUrl’ => ‘/frontend’

I am getting 404 error if i access frontend/site/index.My htaccess in root folder is like this.

RewriteCond %{REQUEST_URI} ^/(frontend)
RewriteRule ^.*$ frontend-web/index.php [L]

Should not be required.

Working now.
I just moved my htaccess to public_html from app2 folder. I didn’t notice that before.Thank you.
All of my internal apps uses their respective controllers and respective db’s. At the same time for some common methods and for some common data they are using an another global database.So i have created a central module in common folder and a common controller in that which is accessible by all the internal apps for common methods.Is it a right move?Need some suggestions from your side.

Yes, that is OK.

Thank you!!