1 ) server_name directives are primarily used to configure name-based virtual hosts ( inside the http > server ), server_name The order in which the instructions are received after the request is:
1 . accuracy of server_name matches, for example:
server {
Listen 80;
Server_namessdr.infowww.ssdr.info;
...
}
2 . in * string starting with the wildcard character:
server {
Listen 80;
Server_name*.ssdr.info;
...
}
3 . in * A string that ends with a wildcard character:
server {
Listen 80;
server_name www.*;
...
}
4 . match Regular expression:
server {
Listen 80;
server_name~^ (?. +) \.howtocn\.org$;
...
}
Nginx will follow 1,2,3,4 the order of servername match, only one match will stop the search .
2 ) in a Server Configure multiple level two domain names for a single site in a block :
in the actual site directory structure, we usually create a separate directory for the site's level two domain name, and we can use regular captures to implement a Server To Configure multiple level two domain names in a block:
Server
{
Listen 80;
Server_Name ~^ (. +)? \.domain\.com$;
Index index.html;
if ($host = domain.com) {
rewrite ^ http://www.domain.com permanent;
}
root/data/wwwsite/domain.com/$/;
}
The directory structure of the site should be as follows:
/data/wwwsite/domain.com/www/
/data/wwwsite/domain.com/nginx/
This access www.domain.com when Root Directory is /data/wwwsite/domain.com/www/ , nginx.domain.com when the /data/wwwsite/domain.com/nginx/ , and so on.
back if The purpose of the statement is to domain.com REDIRECT the orientation to the www.domain.com , which resolves both the Web site's home directory access and the ability to add SEO in the www.domain.com 's domain weight.
3 ) Multiple regular expressions:
If you are in server_name With the regular, and the following Location The field also uses a regular match so that it cannot be used $ , $ such a reference, the workaround is to pass Set The directive assigns the value to a named variable:
Server
{
Listen 80;
Server_Name ~^ (. +)? \.howtocn\.org$;
Set $www _root $;
root/data/wwwsite/ssdr.info/$www _root/;
Location ~. *\.php?$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename/data/wwwsite/ssdr.info/$fastcgi _script_name;
Include Fastcgi_params;
}
}
The above describes the Nginx server_name configuration, including the server,nginx aspects of the content, I hope that the PHP tutorial interested in a friend helpful.