Welcome! Log In Create A New Profile

Advanced

Multiple virtual directories with PHP support

Posted by EricHarth 
Multiple virtual directories with PHP support
April 09, 2013 08:01AM
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



Edited 1 time(s). Last edit at 04/09/2013 08:02AM by EricHarth.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 159
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready