I’ve been looking at nginx recently, but I’m not sure what the specific use of alias is. Both root and rewrite can achieve it, why use alias?
root /data/mydomain/main/web/;
location ~* ^/app(|/)$ {
#alias /data/mydomain/main/public/app/;
rewrite ^/app(|/)$ /public/app/ last;
expires 30s;
}
In the above configuration, rewrite takes effect and meets my expectations. But there is a problem with alias.
This is a matter of your own understanding. First of all, rewrite has nothing to do with root and alias.
rewrite is for http requests. The path in it is the address in the URL, which is the conversion between addresses.
The root and alias are the settings of the system file path.
The root in the area is used to set the root directory, and alias is used to reset the directory of the current file.