Skip to content

Nginx root vs alias

Henryk Paluch edited this page Jul 1, 2016 · 2 revisions

When porting Apache Alias to Nginx it is very easy to do such mistake:

# Apache: Alias /ks  /opt/images
# Nginx: WRONG WAY:
location /ks/ {
		root /opt/images/;
}

This is wrong! The URL http://localhost/ks/ is mapped to /opt/images/ks by Nginx (but in Apache it maps just to /opt/images)

The right way is to use Nginx's alias option:

location /ks/ {
		alias /opt/images/;
}

Now it should work as expected by Apache webmasters...

Clone this wiki locally