Nginx does not seem to have a virtual directory, because it is completely based on the directory to design and work. If you want to give nginx a virtual directory, it is only the alias tag comparison "like", simply say the alias tag and root tag differences. The basic difference: the directory specified by alias is accurate, root is the parent directory of the specified directory, and the parent directory will contain the directory with the same name as the location specified. Also, according to the previous article, the rewrite break cannot be used in a directory block that uses the alias tag.
Don't understand, look under configuration:
location/abc/{
alias/home/html/abc/;
}
In this configuration, the http://test/abc/a.html is specified as/home/html/abc/a.html. This configuration can also be changed to
location/abc/{
root/home/html/;
}
In this way, Nginx will find the/home/html/directory under the ABC directory, the results are the same. However, if I change the alias configuration to:
location/abc/{
alias/home/html/def/;
}
Then Nginx will take data from/home/html/def/, this configuration is not directly using the root configuration, if not to configure, only under the/home/html/to establish a DEF->ABC soft link (shortcut). In general, it is a good practice to configure alias in Location/other by configuring root in Location/. As for the difference between alias and Root, I guess it hasn't been said completely, if you find a singular problem in the configuration, you might want to change the two for a try.
Settings for Nginx alias
Nginx also has an alias function like Apache, in the form of:
Location ~/alias {
Root/home/www/default;
Index index.php;
}
But nginx in the processing of PHP script, need to pass to fastcgi to handle, so more than Apache alias settings, the following we set the phpMyAdmin alias as an example:
Location ~ ^/phpmyadmin.+.php$ {
Root/home/www/default;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
Location ~/phpmyadmin {
Root/home/www/default;
Index index.php;
}
Nginx set alias to implement the virtual directory alias and root usage difference