Override index.php for a subdirectory

Lorenzo Milesi maxxer at ufficyo.com
Wed Dec 18 15:05:04 UTC 2013

> You will probably want your new location, which will probably use "^~",
> to be in the same server{} block as the rest of your configuration.

Thanks for your suggestion. 

For benefit of others I solved this way:

server {

    location /work/management_site/ {
        location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
            try_files $uri =404;
        set $yii_bootstrap "index-maxxer.php";
        index index-maxxer.php;
        try_files $uri $uri/ /work/management_site/index-maxxer.php?$args;
        set $fsn /$yii_bootstrap;
        if (-f $document_root$fastcgi_script_name){
            set $fsn $fastcgi_script_name;

        fastcgi_index index-maxxer.php;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;

It can probably be improved, but right now it works!

Thanks again
Lorenzo Milesi - lorenzo.milesi at yetopen.it

YetOpen S.r.l. - http://www.yetopen.it/

More information about the nginx mailing list