In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to redirect the secondary domain name to the primary domain name in website development. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In order to increase the search engine friendliness of www.yisu.com, we made a 301redirect to this site today.
Redirect jb51.net to www.yisu.com
The solution is as follows:
Locate the .htaccess file in the site directory (if not, create one. Note: there is a dot in front of htaccess), add this line of code:
The code is as follows:
RewriteEngine on
RewriteCond% {http_host} ^ jb51.net
RewriteRule ^ (. *) $https://www.yisu.com/$1 [Rust 301m L]
Then reopen the old domain name to have a look.
Everything OK up!
The function of .htaccess is very powerful, if you don't know it, you might as well search the Internet! However, this file can only be used in UNIX or linux hosts for 301 redirects, and this method is obviously not allowed if you are using ASP space.
Appendix:
Seven common methods to realize 301 redirection
301 redirection is no stranger to webmasters. From website construction to directory optimization, changes to site directories cannot be avoided. In this case, old addresses may still be saved in users' favorites and search engines. 404 errors will occur when opening these links, resulting in a poor user experience and loss of a lot of traffic. Today, Yuanyuan will share with you seven ways to achieve 301 redirection.
From the point of view of search engine optimization, 301 redirection is the most feasible way to redirect after the change of website directory. After you change the address and use 301 redirection, the search engine will only index the new address and transfer the original links under the old address to the new address, and the above actions will not affect the ranking of the site in the search engine.
The most direct way to achieve 301 redirection is to edit the .htaccess file. For more information about how to use the htaccess file, please click here. The garden needs to remind you that before operating on the .htaccess file, be sure to back up the original .htaccess file to avoid unnecessary trouble caused by modification errors.
1. Redirect domain.com to www.domain.com
This kind of redirection is very common, and the ultimate goal is to achieve the uniqueness of the domain name, which is what seo must do. This is done by adding the following rules to the .htaccess file:
The code is as follows:
RewriteEngine On
RewriteCond% {HTTP_HOST}! ^ www.domain.com$ [NC]
RewriteRule ^ (. *) $http://www.domain.com/$1 [Lme Rome301]
Note: after using this 301 redirect method, when you open a URL similar to domain.com, you will be automatically directed to www.domain.com.
two。 Redirect www.domain.com to domain.com
This operation is just the opposite of the domain name shown above, and the rules are as follows:
The code is as follows:
RewriteEngine On
RewriteCond% {HTTP_HOST}! ^ domain.com$ [NC]
RewriteRule ^ (. *) $http://domain.com/$1 [Lme Rome301]
Note: using this 301 redirect method, when you open a URL similar to www.domain.com, you will be automatically directed to domain.com.
3. Redirect olddomain.com to newdomain.com
This operation is often used to change the domain name. Many webmasters may have to change the domain name for the site for various reasons. The following rules are often used to achieve redirection:
The code is as follows:
RewriteEngine On
RewriteBase /
RewriteCond% {HTTP_HOST}! olddomain.com$ [NC]
RewriteRule ^ (. *) $http://newdomain.com/$1 [Lme Rome301]
Note: when the user opens the old domain name, it will be automatically redirected to the site under the new domain name, and the domain name will be displayed without www. The format of.
4. Redirect olddomain.com to www.newdomain.com
This operation is based on an improvement of the third way, except that the URL is displayed with www. That kind of thing.
The code is as follows:
RewriteEngine On
RewriteCond% {HTTP_HOST}! olddomain.com$ [NC]
RewriteRule ^ (. *) $http://www.newdomain.com/$1 [Lme Rome301]
Note: when the user opens the old domain name, it will be automatically redirected to the site under the new domain name, and the URL is displayed in the format with www. The format of.
5. Redirect domain.com/file/file.php to otherdomain.com/otherfile/other.php
This operation is used when you change a domain name and the directory path of the website also changes. The rules are as follows:
The code is as follows:
RewriteCond% {HTTP_HOST} ^ www.domain.com$
RewriteRule ^ file/file.php$ http://www.otherdomain.com/otherfile/other.php [Renew301 Magi L]
Note: when users access the old domain name path, they will be redirected to the new domain name and new path.
301Redirection under 6.IIS Server
The specific methods are as follows: open the internet Information Services Manager, right-click on the page or directory that you want to redirect, select "Redirect to URL", enter the address of the target page in the dialog box, and remember to select "permanent redirection of resources" and finally click "apply".
Note: remind you again, be sure to select "permanent redirection of resources".
7.Apache server implements 301 redirection
As mentioned in the previous article, you only need to add the following rules to the .htaccess file in the method garden for implementing redirection on the Apache server:
The code is as follows:
Redirect / old directory / old document name address of the new document
It could also be:
The code is as follows:
Redirect / olddirectory http://www.newsite.com/newdirectory
Note: be sure to pay attention to the writing format, the first is to direct a document to a new directory address under the same domain name, and the second is to define the old directory to the new directory of the new domain name. For more information about the application of .htaccess, please see: htaccess file usage.
The above seven methods are 301 redirection methods that are often used in the process of website management and optimization. Of course, you may encounter different situations. At this time, you need to adjust the command rules according to your own purpose to meet different needs.
On the website development of how to redirect the secondary domain name to the primary domain name solution 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.