php - nginx $document_root with subdirectories insert the subdirectory in its path -


i'm working subdirectories. want "babylon/webmail" go rainloop webmail client.

location ^~ /webmail {     root /srv/rainloop/public_html;     try_files $uri $uri/ /webmail/index.php?$query_string;     access_log /srv/rainloop/logs/access.log;     error_log /srv/rainloop/logs/error.log;     index index.php;     access_log /var/log/nginx/scripts.log scripts;      location ~ \.php$ {         #fastcgi_index index.php;         #fastcgi_split_path_info ^(.+\.php)(.*)$;         #fastcgi_keep_conn on;         #include /etc/nginx/fastcgi_params;         #fastcgi_pass unix:/var/run/php5-fpm.sock;         #fastcgi_param script_filename $document_root$fastcgi_script_name;          #try_files $uri =404;         include fastcgi_params;         fastcgi_pass unix:/var/run/php5-fpm.sock;         fastcgi_index index.php;         #fastcgi_param script_filename $document_root$fastcgi_script_name;         fastcgi_param script_filename /srv/rainloop/public_html/index.php;         #include fastcgi_params;     }      location ~ /\.ht {         deny all;     }      location ^~ /webmail/data {         deny all;     } } 

however

fastcgi_param script_filename $document_root$fastcgi_script_name; 

doesn't work @ all. prints out: /srv/rainloop/public_html/webmail/index.php; file doesn't exist in directory structure, but: /srv/rainloop/public_html/index.php

fastcgi_param script_filename /srv/rainloop/public_html/index.php; 

p.s.: after hardcoding, don't error @ all, page blank rainloop code source code.

the path file calculated concatenating value of root uri. uri contains /webmail/index.php, otherwise not match location block.

you mean use alias instead of root directive removes value of prefix location when calculating path file. see this document details.

location ^~ /webmail {     alias /srv/rainloop/public_html;     if (!-e $request_filename) { rewrite ^ /webmail/index.php last; }      ...      location ~ \.php$ {         if (!-f $request_filename) { return 404; }         include fastcgi_params;         fastcgi_param script_filename $request_filename;         fastcgi_pass unix:/var/run/php5-fpm.sock; } 

avoid using try_files , alias in same block, due this long term issue, , see this caution on use of if. use $request_filename script_filename value.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -