Open the nginx installation directory/conf/nginx. conf file, find the http curly brackets, and add the following code.
The code is as follows: |
Copy code |
Server { Listen 80; # port, which is usually the default value (required) Server_name www.111cn.net 111cn.net; # domain name. Multiple domain names are separated by spaces (required) Index index.html index.htm index. php; # default homepage document. Multiple documents can be added (required) Root/data0/htdocs/www.111cn.net; # VM Directory (required) # -- Automatically complete www (not necessary) before the domain name )--# If ($ host! = 'Www .111cn.net '){ Rewrite ^/(. *) $ http://www.111cn.net/#1 permanent; } # -- Domain name completion --# # -- For WordPress pseudo-static -- (optional )--# If (-f $ request_filename/index.html ){ Rewrite (. *) $1/index.html break; } If (-f $ request_filename/index. php ){ Rewrite (. *) $1/index. php; } If (! -F $ request_filename ){ Rewrite (. *)/index. php; } # -- WordPress pseudo-static end --# # -- PHP support -- if you build a PHP environment, add this section --# Location ~ . *. (Php | php5 )? $ { # Fastcgi_pass unix:/tmp/php-cgi.sock; Fastcgi_pass 127.0.0.1: 9000; Fastcgi_index index. php; Fcinclude GI. conf; } # -- PHP support end --# # -- Additional configuration. It is best to remove this configuration if it is run online. For example, the first line indicates opening the search (insecure )--# Autoindex on; Autoindex_exact_size off; Autoindex_localtime on; # -- Additional configuration --# # Log on (latest version format) Access_log/data1/logs/access_qttc.log logs; } |
Copy the above code to nginx. conf and save and restart nginx to take effect.