根据条件将文档根目录内部重定向到另一个文件夹

I currently have the following setup:

*.mysite.com --> /home/public_html/app/index.php

I want to write some code in index.php that changes the whole document root to /home/public_html/app_prev/index.php based on a condition. The reason for this is that I am doing a migration and if they haven't been migrated yet, I want to serve the old version of the code; once they are migrated. Each user has their own database and I will migrate 1 by 1. Normally it would take seconds to migrate all of them, but this release will take awhile to do.

  1. Is this possible?
  2. Is this recommend when making large database schema changes? Will it cause performance problems/errors?
  1. You could just use a PHP redirect based on the condition that you're looking for. It's no different then serving a different page based on what's coming in.
  2. It's a reasonable implementation if you have many large databases and you're worried about performance. I'd test it by
    1. Keep the old code path and old database.
    2. Migrate a test database over to the new codebase. I don't know how you're doing your logic, but you could have a single column, one entry table in each database that describes whether it's on the old or new code base.
    3. Test that the new codebase works.
    4. Start migrating your databases over, changing that single entry in each database (or however your logic is determined).