I need help configuring nginx to download files from another folder. Here is my configuration:
index index.php; server { server_name domain.com; root /www/domain.com/www/; location / { try_files $uri $uri/ /php_www/index.php; } location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index /php_www/index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include /etc/nginx/fastcgi_params; } error_page 404 /404.html; error_log /var/log/nginx/error.log; }
The problem is that / php_www / is not inside the root defined in nginx.
I have 4 different folders that I need to do, here is what my folder structure looks like:
/www/domain.com/www/ /www/domain.com/php_www/ /www/domain.com/content1/ /www/domain.com/content2/
What I'm trying to do is when a visitor goes to domain.com/page1/content1/
, for example, I want to download content from the folder content1. The reason for this is that I have several git projects with separate repositories ... this will allow me to push some areas of the website to production without doing anything else. I would not want all my files / content to be available in the / www folder, so the URLs cannot be brutally searched for content.
Hope this makes sense!
Working solution (extracted from this comment)
location ^~ / { root /www/domain.com/php_www/; try_files $uri $uri/ /index.php; location ~* \.(?:php|html)$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_params; } }
tvpmb source share