How parse subdirectory to a module (and their other params)

The problem:

I can’t run Yii Application in document root (like http://domain.com)

.htaccess, index.php, nothing in the document root :blink:

What’s my objective:

Identify directories as modules in the application, then, redirect to they.

Example:

http://domain.com/site1 -> yii/modules/Site1Module/DefaultController

http://domain.com/Site1/subscription -> yii/modules/Site1Module/SubscriptionController

http://domain.com/Site2/contact?whatsapp -> yii/modules/Site2Module/ContactController (get whatsapp var)


I’m try to bootstrap all in my DefaultController root application:




class DefaultController extends Controller

{


	public function actionIndex()

	{


		$baseUrlModule = substr(Yii::app()->getRequest()->baseUrl, 1);

		$baseRequestUri = substr(Yii::app()->getRequest()->requestUri, 1);


		if(Yii::app()->hasModule($baseUrlModule))

		{

			$this->redirect(array(Yii::app()->getRequest()->requestUri));

		} 

		else 

		{

			echo '404';

		}


	}


}



Then, in each directory will be copied index.php to Yii::createWebApplication …

But unfortunately it did not work. How can I fix this?