In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article uses easy-to-understand examples to introduce how the virtual host to do 301 redirection, the content is very detailed, interested friends can refer to, hope to be helpful to you.
The virtual host 301 redirection can be realized by setting the 301 redirection rule and putting the generated files into the root directory.
When do I need to do a 301 redirect? First, in order to standardize URL, centralized weight; second, the website revision, the old version of the page transferred to the new version of the page.
For example, there are several types of URL on the front page of a website:
Xxx.com
Www.xxx.com
Xxx.com/index.html
Www.xxx.com/index.html
As well as HTTP pages and HTTPS pages. There are so many URL on a home page, one is irregular, the other is weight dispersion, then we need to unify all the URL pointing to the home page to a certain one, such as: www.xxx.com or https://www.xxx.com/.
And the URL of the page has changed, so we also need to do a 301 redirect to prevent the old URL from generating 404.
So how do we do the 301 redirection? To distinguish between a Linux virtual host and a Windows virtual host, the redirection rules are different.
Linux virtual host, generally pseudo-static rules are put into .htaccess file.
RewriteEngine OnRewriteCond% {HTTP:From-Https}! ^ on$ [NC] RewriteCond% {HTTP_HOST} ^ (www.)? xxx.com$ [NC] RewriteRule ^ (. *) $https://www.xxx.com/$1 [Rene301 Magi L]
# Jump xxx.com and www.xxx.com to https://www.xxx.com, to prevent the apache substation from inheriting the parent directory. .htaccess is affected. Delete the comments by yourself and do not need to put the htaccess file.
If there are multiple requirements, such as: a.com to www.a.com;b.com to www.b.com, the rules are as follows:
RewriteEngine OnRewriteCond% {HTTP_HOST} ^ a.com $[NC] RewriteRule ^ (. *) $http://www.a.com/$1 [RewriteCond 301 Magi L] RewriteCond% {HTTP_HOST} ^ b.com $[NC] RewriteRule ^ (. *) $http://www.b.com/$1 [Renew301 Magi L]
Add changes according to your website needs, and then upload the rules to the .htaccess file in the server's wwwroot root directory. If there is no .htaccess file, create a new text document and rename it .htaccess.
Windows virtual host, generally pseudo-static rules are put into the web.config file.
# www.xxx.com should be modified to your own domain name. Delete the comments by yourself and do not need to put them in the web.config file.
About the virtual host how to do 301 redirection to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.