位置中的另一个根/别名产生403

我不希望phpMyAdmin在我的网站的文件夹,但他们应该分别访问http://test.example.sitehttp://test.example.site/phpMyAdmin 。 但是这个configuration似乎不起作用:

  • 403上http://test.example.site/phpMyAdmin
  • http://test.example.site/phpMyAdmin/index.phpNo input file specified

configuration如下。

 server { server_name test.example.site; error_log /var/log/nginx/test.error.log error; access_log /var/log/nginx/test.access.log; root /home/me/test/www-site; gzip on; gzip_types application/x-javascript application/javascript text/javascript text/css; client_max_body_size 50m; location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 1M; } location / { index index.php index.html index.htm; } location /phpMyAdmin/ { # one of those is included, both don't work alias /home/me/test/phpMyAdmin; root /home/me/test/; } location ~ \.php { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } 

您不能同时通过几个兄弟location指令终止请求(除非您进行URL重写)。

  • 您的请求http://test.example.site/phpMyAdmin返回403因为location /phpMyAdmin/不能有索引文件( location /index指令不适用),并且目录列表是不允许的。

  • 您的请求http://test.example.site/phpMyAdmin/index.php可以同时只适用于一个位置。 因此,它被location ~ \.php/home/me/test/www-sitelocation ~ \.php处理,因为来自location /phpMyAdmin/的指令不适用。

同样,指令aliasroot是相互排斥的。