我有一个Drupal应用程序和其他2个应用程序写在PHP中,我想使用重写Uri的Drupal,并将Drupal的虚拟根/另一个由他们的名字…并使用服务器caching的每个应用程序的IMG。
例如:
我已经testing:别名,根在每个位置,条件$ request_uri,单独的configuration…总是一个错误:IMGpath,PHPpath,所有应用程序或Drupal之一404
所以我真的迷路了
这里testing(也许有些好东西):
# enforce www if ($host !~* ^(www)) { rewrite ^/(.*)$ $scheme://www.$host/$1 permanent; } location / { root /var/www/gplaza.cl/Drupal; index index.php index.html; if (!-f $request_filename) { rewrite ^(.*)$ /index.php?q=$1 last; break; } if (!-d $request_filename) { rewrite ^(.*)$ /index.php?q=$1 last; break; } } location /app1/ { alias /var/www/gplaza.cl/app1/; index index.php; } location /app2/ { alias /var/www/gplaza.cl/app2/; index index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/xxx.com$fastcgi_script_name; } location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ { set $static_content /var/www/xxx.com/Drupal; if ($request_uri ~ ^/app1) { set $static_content /var/www/xxx.com/app1; } if ($request_uri ~ ^/app2) { set $static_content /var/www/gplaza.cl/app2; } expires 30d; access_log off; root $static_content; } thank a lot if anybody can help me :)
位置指令以预定义的顺序( http://wiki.nginx.org/HttpCoreModule#location )检查。 在你的情况下,PHP文件的正则expression式是anccachingpipe理首先考虑,然后/位置和(如果/不应该匹配)/ app1 /和/ app2 /指令。 由于root始终会匹配,所以/ app1 /永远不会被检查。
解决方法很简单:将/ app1 /和/ app2 /放在/ -location指令之前,并重新加载nginxconfiguration。
BurninLeo