question: If www.111.com site root directory for/data/web/, now want to www.111.com a site, www.111.com/abc/
However, you cannot create an ABC directory directly under/data/web/, and you should place it under/data1/abc/.
Workaround:
Using the Nginx alias feature to implement a virtual directory
In the configuration file, add
Location ~/abc/(. *) $ {
alias/data1/abc/$1;
}
Of course, alias after the directory can be arbitrary, as long as you put the program directory. In other words, the/data1/abc/defined behind alias can also make/data1/123/
At this time, access to pictures, Web pages, CSS and JS are no problem, but access to PHP will be reported 404. What to do?
Continue to add the following configuration, but note that it should be added in front of the location configuration above, otherwise it will not take effect.
Location ~/abc/.+\.php$ {
root/data1/;
rewrite/abc/(. *\.php)/$1 break;
Include Fastcgi_params;
Fastcgi_pass Unix:/tmp/php-fcgi.sock;
Fastcgi_index index.php;
Fastcgi_param script_filename/data1/abc/$fastcgi _script_name;
}
In this, you can also support PHP.
This article is from the Linux OPS blog, so be sure to keep this source http://zhumy.blog.51cto.com/11647651/1826886
Nginx Configuration virtual directory and support PHP