Last update at :2024-06-20,Edit by888u
When we build a website, we will use the domain name with or without WWW as the main domain name according to our own habits. There are not too many strict regulations on this distinction: we must use WWW or non-WWW domain names, but in foreign countries There are more non-WWW sites on the site, and we in mainland China tend to use domain names with WWW sites.
At the same time, in many so-called website optimization theories, some so-called experts mentioned that 301 jumps must be performed. If you use WWW, you must jump non-WWW to the WWW domain name, otherwise the so-called weight will be lost. It is not clear whether it is a real snail, because some users mentioned that when using the AMH panel, they did not know how to set the 301 jump, because they may be used to using the apache environment and can directly set it in the .htaccess file.
The AMH panel uses the Nginx environment, so similar to the LNMP one-click package environment, you can directly modify the .CONF configuration file to perform 301 jump settings (LNMP series tutorial 5: How to set up 301 redirection). If we are using an AMH panel, we need to do this.
First, if you use the WORDPRESS program
If we use the WORDPRESS program, Snail finds that it does not need to set 301 and will automatically jump. This is like this in the AMH panel environment, but not in the LNMP environment. It may be due to the mechanism of the internal environment and It has something to do with the default structure of the WP system. When we create a WP site, if we use WWW to open the installation directly, all the sites will jump to the WWW domain name by default. If we need to modify it, we can directly set whether to use WWW as the main domain name in the WP backend site settings.
Second, other program environments
For other environments, we still do the same and modify the .CONF file of the corresponding site. Found:
/usr/local/nginx/conf/vhost/
In the directory file, find the .conf file corresponding to the site domain name, such as laozuo.org.conf
Seeing the picture above, we add in the corresponding position:
if ($host != \\’www.laozuo.org\\’ ) {rewrite ^/(.*)$ https://www.laozuo.org/$1permanent;}
The above script can be modified to the URL of our own site. If we need it without WWW, we can achieve it by removing WWW. Finally, we need to execute amh nginx restart to restart nginx to take effect.
To summarize, the above simple recording method requires users to record the site 301 jump when using the AMH panel, so that friends in need can copy and use it for reference.
Recommended site search: free cloud computer host permanent use, Korean independent server, check IP address, China's top ten domain name registrars, the best American server, permanent free vps cloud host, virtual host purchase, ICP registration center, China Registration-free space in mainland China, server rental in Hong Kong,
发表评论