Frontend and backend structure to share common files and htaccess

I m beginner in yii

I have created one structure to handle files for frontend and backend so that common files can be used for both and different files form their folder


  framework/ (This folder will contain all yii framework core folders and files)          


   assets/


   js/





      [indent]frontend/[/indent]





      [indent]common/[/indent]





      [indent]backend/[/indent]





      [indent]api[/indent]





 images/


 storage/


      


 protected/


         components/


         config





             main.php   (DB, emails, etc...)





         controllers/





             [indent] frontend/[/indent]





             [indent] backend/[/indent]





         views/





               [indent] frontend/[/indent]





               [indent] backend/[/indent]





        models/       


        extensions/


        modules/  


        


        runtime/


        index.php


        .htaccess

this structure is created for booking application.

Some common files are shared between them it will be there in controller/ and views/

and differnrt file will be in controller/frontend/ and controller/backend/

Example

I have files in both folder as below

controller/

 [indent]SiteController.php[/indent]


 [indent]Frontend/SiteController.php[/indent]


 [indent]Backend/SiteController.php[/indent]

views/

[indent]layouts/[/indent]

[indent]Frontend/layouts[/indent]

[indent]Backend/layouts[/indent]

Now the question is how can i set .htaccess so that

when i write http://myapp.com/index.php --> will access all files for frontend

and

http://myapp.com/backend/inex.php --> will access backend files (beckend views and controller)

thanks in advance