我的nginx conf不允许真正的文件夹访问和索引

我安装了Cockpit CMS,并且使用这个conf文件,我想要共享或访问的文件或子网站的每个实际文件夹都被解释为404页,我猜是因为这个部分:

location / { try_files $uri /index.php$uri?$args; } 

然后我需要指定每个链接和文件夹来启用访问。 这是有点约束。 你有避免这个问题的想法吗?

 server { listen 443 ssl; ... server_name site.com; root /var/sites/_site.com/www; index index.php index.html; location / { try_files $uri /index.php$uri?$args; } location /cockpit { try_files $uri $uri/ /cockpit/index.php; } # Enable PHP with path_info location ~ ^(.+\.php)($|/) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } # Files index location /files { autoindex on; } location /specific-link {} location /specific-folder {} } 

也许这个语法变体会帮助你?

  try_files $uri $uri/ /index.php$uri?$args; 

如果文件夹没有物理存在,它会在将文件传递到后端之前尝试文件夹和文件。