Running Yii1.1 and Yii2 on the same server

My company needs to figure out a way to run Yii1.1 and Yii2 on the same server. Yii1 will only be used for a certain module. For example:

"http://www.example.com/v1/user/loaduser" needs to map to Yii1.

Everything else can go to Yii2. So "http://www.example.com/v2/user/loaduser" and "http://www.example.com/v3/user/loaduser" would map to Yii2.

We’ve been attempting to do this with Apache 2.2, but cant seem to get it to work. Here’s what we’ve been playing around with in the apache config:




# sending v1 to Yii1

Alias /v1 "/var/www/html/api/api"


<Directory /var/www/html/api/api>

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . index.php

</Directory>


# send everything else to yii2

# Set document root to be "basic/web" 

DocumentRoot "/var/www/html/api_yii2/web"


<Directory "/var/www/html/api_yii2/web">

    # 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...

</Directory>

Any advice on how to get this working? Thanks.

The simplest way i could think of is to make the yii2 site the main site. Create a folder in the web root called v1 and put yii1 site there and adjust the url rules appropriately. You may also need to configure the default action for the yii1 site too.