springmvc-web site tomcat server Nginx configuration 301 redirection

springmvc-web site tomcat server Nginx configuration 301 redirection! The customer made a request and wanted to be the root domain name, redirecting to the domain name of www. I searched for information on the Internet, and after doing the following deployment, it succeeded.

Share it below for your reference.

1. You only need to modify the nginx configuration file. As shown below.

As shown in the figure, add the root domain name, and then add the following piece of code. It is the key code for nginx server to do 301 redirection design.

If there is a request for the root domain name, it will be automatically directed to the domain name of www.xxx.com to respond to the request.

Digression:

Many netizens on the Internet are trying to find a way to use the urlrewriter.xml configuration file to do 301. In fact, that method is too cumbersome. Not suitable. It is recommended that you use the nginx server to do it, which is simple and fast. 2 lines of code did the trick.

Features:

There is no need to change the previous configuration and code, just add 2 configuration parameters to achieve the effect of 301 redirection.

Guess you like

Origin blog.csdn.net/yrldjsbk/article/details/129212904