Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Multiple virtual directories with PHP support

$
0
0
Hi

I've been trying for quite a while now to get multiple virtual directories working under a single server block. I seem to be able to get part of the way there but fail at the last hurdle.

server {
listen 80;
server_name api.domain.co.uk;

root /var/www/html/api/current;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;

location ~ /v02(.*){
rewrite ^/v02(.*) $1;

root /var/www/html/api/v0.2;
try_files $uri $uri/ index.php?$args;

location ~ \.php$ {
rewrite ^/v03(.*) $1 last;
rewrite ^ http://$document_root$fastcgi_script_name;
try_files $uri =401;
include fastcgi_params;
}
}

location ~ /v03(.*){
rewrite ^/v03(.*) $1;

root /var/www/html/api/v0.3;
try_files $uri $uri/ index.php?$args;

location ~ \.php$ {
rewrite ^/v03(.*) $1 last;
rewrite ^ http://$document_root$fastcgi_script_name;
try_files $uri =401;
include fastcgi_params;
}
}

location / {
try_files $uri $uri/ /index.php?$args;
}
}


I need to get multiple stand alone sites running so that they can be versioned as shown with urls such as http://api.domain.co.uk/v03/api/.... The sites have a CMS behind them that requires any pretty urls to be passed to the bootstrap file (index.php). I could get it as far as being to execute specific calls to php files but not so that it'd pass pretty urls to index.php.

Any help would be much appreciated. Please let me know if there are any questions.

Many thanks

Eric

pastebin formatted version http://pastebin.com/BaDpXGfb

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>