Reputation: 20223
I have some static html files under:
/var/www/project1
Nginx config for this project is:
server_name www.project1.com project1.com;
root /var/www/project1;
location / {
index index.html;
}
My goal is to use nginx so that when a user enters this url:
www.project1.com/project2
Nginx uses another root, I have tried:
location /project2 {
root /var/www/project2;
index index.html;
}
But this is not working. Any idea on how to achieve this?
Upvotes: 6
Views: 8110
Reputation: 1582
According to your config of project2
location /project2 {
root /var/www/project2;
index index.html;
}
Nginx will be looking for files under the path /var/www/project2/project2/
for your requests to project2. So if your project2 is under /var/www/project2
, The correct config should be
location /project2 {
root /var/www;
index index.html;
}
Another alternative is to use alias
instead of root
.
in your case is alias /var/www/project2
, check here
Upvotes: 6