我有驾驶舱内容管理系统安装并使用此配置文件后,我想要共享或访问的每个包含文件或子网站的实际文件夹都被解释为 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 {}
}
答案1
也许这种语法变化会对你有帮助?
try_files $uri $uri/ /index.php$uri?$args;
如果文件夹和文件实际上不存在,则会尝试它们,然后将其传递到后端。