Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to realize redirection 301 for cloud virtual host

Shulou Source: shulou.com Published: 2022-06-02 01:36:43 10月23日 Update

How to redirect 301 to a CVM? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

CVM can be redirected to 301. In the control panel of the virtual host, there is a "301 turn" function, where we can set redirect 301 for the URL. Or find the configuration file directly in the virtual host file manager and do the 301 redirection rule.

301Redirection (or 301redirect, 301Jump) is one of the status codes in the header information (header) in the HTTP data stream returned by the server when a user or search engine sends a browsing request to the web server, indicating that the page is permanently transferred to another address. 301 redirect is mainly to redirect the URL that needs to be transferred to another new URL, and it is a permanent transfer.

We take Linux virtual host as an example to explain the method of cloud virtual host redirection 301:

If abc.com and www.abc.com, the two domain names, are unified to www.abc.com, the 301jump rule is established as follows:

RewriteEngine OnRewriteCond% {HTTP_HOST} ^ abc.com$ [NC] # abc.com is correspondingly modified to your own domain name RewriteRule ^ (. *) $http://www.abc.com/$1 [Run301Magi L]

Jump both abc.com and www.abc.com to: https://www.abc.com, then the established 301 turn rule is

RewriteEngine OnRewriteCond% {HTTP:From-Https}! ^ on$ [NC] RewriteCond% {HTTP_HOST} ^ (www.)? abc.com$ [NC] # Jump abc.com and www.abc.com to https://www.abc.com, to prevent apache substations from inheriting the parent directory .htaccess affected by RewriteRule ^ (. *) $https://www.abc.com/$1 [abc.com$ 301jL]

If you need to transfer multiple different domain names to one domain name, such as 123.com, and also to abc, the redirection rule for virtual host 301 is as follows:

RewriteEngine OnRewriteCond% {HTTP:From-Https}! ^ on$ [NC] RewriteCond% {HTTP_HOST} ^ (www.)? abc.com$ [NC] RewriteRule ^ (. *) $https://www.abc.com/$1 [Ranger 301 Magazine L] RewriteCond% {HTTP:From-Https}! ^ on$ [NC] RewriteCond% {HTTP_HOST} ^ 123.com $[NC] RewriteRule ^ (. *) $https://www.abc.com/$1 [Rene301MAL]

301 jump code copy, put into the root directory of the Linux virtual host .htaccess file, can be achieved. If you don't have this file in the root directory, you can create one yourself and name it .htaccess. In this way, the 301 redirection function will take effect, and we can verify whether it is automatically redirected by entering the relevant original domain name.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Host virtual host domain name file rule URL function server root directory permanent permanent help service different clear superior two code content can be passed through Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno MySQL macOS Shulou Information