I want to define a separate directory for each part of my website on my NGINX server.
domain.com/ --> /var/www/html/domain.com/website
domain.com/blog/ --> /var/www/html/domain.com/blog
domain.com/checkout/ --> /var/www/html/domain.com/checkout
domain.com/download/ --> /var/www/html/domain.com/download
domain.com/forum/ --> /var/www/html/domain.com/forum
The different configurations I've tried don't work, I get 404 errors.
server {
location / {
root /var/www/html/domain.com/website;
}
location /blog {
root /var/www/html/domain.com/blog;
}
}
or
server {
root /var/www/html/domain.com/website;
location /blog {
root /var/www/html/domain.com/blog;
}
}
or
server {
root /var/www/html/domain.com/website;
location /blog/ {
alias /var/www/html/domain.com/blog;
}
}
or
server {
root /var/www/html/domain.com/website;
location /blog/ {
alias /var/www/html/domain.com/blog/;
}
}
or
server {
root /var/www/html/domain.com;
location / {
alias /var/www/html/domain.com/website/;
}
location /blog/ {
alias /var/www/html/domain.com/blog/;
}
}
or
server {
location ~ ^/(?!(blog|checkout|download|forum))/ {
root /var/www/html/domain.com/website;
}
location /blog/ {
root /var/www/html/domain.com/blog;
}
}