How to set backend.php as a default page instead of index.php

I have successfully separate frontend and backend. But I am unable to set this in virtual host. Please check:

Backend virtual host:


<VirtualHost *:80>

    DocumentRoot "C:\xampp\htdocs\myproject"

    ServerName admin.chinmay.com

  <Directory "C:\xampp\htdocs\myproject">

    AllowOverride All

    Order allow,deny

    Allow from all


    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . backend.php

    DirectoryIndex backend.php

    Require all granted


  </Directory>

</VirtualHost>

Frontend virtual host:


<VirtualHost *:80>

    DocumentRoot "C:\xampp\htdocs\myproject"

    ServerName demo.chinmay.com

  <Directory "C:\xampp\htdocs\myproject">

    AllowOverride All

    Order allow,deny

    Allow from all

  </Directory>

</VirtualHost>

See above code my backend.php file which is not working for inner pages.

admin.chinmay.com this is working fine but when I call other controller action I got index.php instead of backend.php

I want all the action and sub-action which comes under admin.chinmay.com should load backend.php file.

How to manage it?

Please help.

Hmm, I don’t understand why you have to share the DocumentRoot for both “admin.chinmay.com” and “demo.chinmay.com”.

I have setup vhost but exactly don’t know how to do that. I searched and got this way.

I would keep the things simple.

Assuming you have installed the advanced application template to "C:\xamp\htdocs\myproject" …

Backend virtual host:


<VirtualHost *:80>

    DocumentRoot "C:\xampp\htdocs\myproject\backend\web"

    ServerName admin.chinmay.com

  <Directory "C:\xampp\htdocs\myproject\backend\web">

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . index.php

    ...

  </Directory>

</VirtualHost>



Frontend virtual host:


<VirtualHost *:80>

    DocumentRoot "C:\xampp\htdocs\myproject\frontend\web"

    ServerName demo.chinmay.com

  <Directory "C:\xampp\htdocs\myproject\frontend\web">

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . index.php

    ...

  </Directory>

</VirtualHost>



[color="#556B2F"]/* Moved from "2.0" to "1.x", since @Chinmay is working with Yii 1.x */[/color]

Thanks @softark

I am still waiting for your expert reply.

I’m sorry, Chinmay, but I have no experience in creating both backend and frontend on the same DocumentRoot as you are trying to do. Also the wiki you’ve mentioned looks too complex to me. (You know, I’m extremely fond of simpleness and easiness.)

What I can say is that you will be happier if you follow the standard way of doing, that is, constructing backend and frontend on the different DocumentRoots.

And consider using Yii 2.0, if you haven’t written a lot so far using Yii 1.1. Yii 2.0 is much sweeter. :)