apache - How to route specific URL segments to separate web root directories? -


my yii project has following structure:

webapp   ----frontend   --------www   ------------index.php ----backend   --------www   ------------index.php   ----api   --------www   ------------index.php 

https://github.com/tonydspaniard/yiinitializr-advanced

apache 2.2

each www directory has own .htaccess file. example "webapp/frontend/www/.htaccess":

options +followsymlinks  rewriteengine on  rewritebase /  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d  rewriterule ^([^/].*)$ /index.php/$1 [l] 

for separate parts of application use subdomains "api.webapp.com","admin.webapp.com" (symlinks in public_html folder):

webapp.com -> webapp/frontend/www    api.webapp.com -> webapp/api/www   admin.webapp.com -> webapp/backend/www 

but have problems cross domain ajax requests api, , want this:

http://webapp.com -> webapp/frontend/www/index.php   http://webapp.com/api/ -> webapp/api/www/index.php    http://webapp.com/admin/ -> webapp/backend/www/index.php    

what right way route url segment specific web root directory? aliases, .htaccess, symlinks, maybe else?

thanks, guys. have 2 working solutions:
1) alex akr
webapp root
webapp/.htaccess:

rewritecond $1 ^api\/ rewriterule ^(.*) api/www/index.php [l,pt]  rewritecond $1 ^admin\/ rewriterule ^(.*) admin/www/index.php [l,pt]  rewriterule . frontend/www/index.php 

2) webapp/frontend/www root.
in apache config set aliases:

alias /api /var/www/webapp/data/www/webapp/api/www <directory /var/www/webapp/data/www/webapp/api/www>     options indexes multiviews followsymlinks     allowoverride     order allow,deny     allow </directory> 

in /webapp/api/www/.htaccess

rewriteengine on  # if directory or file exists, use directly rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d  # otherwise forward index.php rewriterule ^([^/].*)$ /api/index.php/$1 [l] 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -