To increase the search engine friendliness of the website www.miaosha007.com, a 301 redirection is made to the website today,
Redirect miaosha007.com to www.miaosha007.com
The solution is as follows:
Find the. htaccess file under the site directory (if not, create one. Note: There is a point before htaccess). add such a line.Code:
Rewriteengine onrewritecond % {http_host} ^ miaosha007.comrewriterule ^ (. *) $ http://www.miaosha007.com/#1 [R = 301, l]
And then re-open the old domain name to see ......
Everything is OK!
. Htaccess is very powerful. If you do not know it, You may search for it online! However, only UNIX or Linux Hosts can use this file for 301 redirection. If you are using an ASP space, this method is obviously not supported.
Appendix:
Seven common methods for 301 redirection
301 redirection is no stranger to the majority of webmasters. From website construction to directory optimization, you cannot change the website directory, in this case, the user's favorites and search engines may still store the old address. When you open these links, the page cannot be displayed with the 404 error, this results in poor user experience and a lot of traffic loss. Today, garden : 0px; "> seven methods for 301 redirection .
From the perspective of search engine optimization, the current 301 redirection is the most feasible way to redirect a website directory after modification. After you change the address to use 301 redirection, the search engine only indexes the new address and transfers the original link under the old address to the new address, these operations do not affect the ranking of websites in search engines.
The most direct way to achieve 301 redirection isEdit the. htaccess FileFor more information about how to use the htaccess file, click here. Garden needs to remind you that before you operate the. htaccess file, you mustBackupUse the original. htaccess file to avoid unnecessary troubles caused by modification errors.
1. Redirect domain.com to www.domain.com
this type of redirection is very common, the final goal is to implement the uniqueness of the domain name , and also Seo is required. Add the following rules to the. htaccess file:
123 |
rewriteengine onrewritecond % {http_host }! ^ Www.domain.com $ [Nc] rewriterule ^ (. *) $ http://www.domain.com/#1 [L, r = 301] |
NOTE: With this 301 redirection method, when you open a website similar to domain.com, it will be automatically directed to www.domain.com.
2. Redirect www.domain.com to domain.com
This operation is exactly the opposite of the above domain name display. The rules are as follows:
123 |
rewriteengine onrewritecond % {http_host }! ^ Domain.com $ [Nc] rewriterule ^ (. *) $ http://domain.com/#1 [L, r = 301] |
NOTE: With this 301 redirection method, you will automatically redirect to domain.com when you open a website similar to www.domain.com.
3. Redirect olddomain.com to newdomain.com
This operation is often used to change the domain name. Many webmasters may need to change the domain name for the site for various reasons. At this time, the following rules are used to achieve redirection:
1234 |
rewriteengine onrewritebase/rewritecond % {http_host }! Olddomain.com $ [Nc] rewriterule ^ (. *) $ http://newdomain.com/#1 [L, r = 301] |
Note: When the user opens the old domain name, it will automatically redirect to the site under the new domain name. At this time, the domain name display format is not in the www. format.
4. Redirect olddomain.com to www.newdomain.com
This operation is based on the third method of improvement, but only shows the web site with www.
123 |
rewriteengine onrewritecond % {http_host }! Olddomain.com $ [Nc] rewriterule ^ (. *) $ http://www.newdomain.com/#1 [L, r = 301] |
Note: When you open an old domain name, it will be automatically redirected to the site under the new domain name, And the URL is displayed in the format of www.
5. Redirect domain.com/file/file.php to otherdomain.com/otherfile/other.php
This operation is used when a domain name is changed and the website directory path is also changed. The rules are as follows:
12 |
rewritecond % {http_host} ^ www.domain.com $ rewriterule ^ file/file. PHP $ http://www.otherdomain.com/otherfile/other.php [R = 301, l] |
Note: When a user accesses the old domain name path, the user will redirect to the new domain name path.
6. 301 redirection under the IIS server
The specific method is as follows: Open the Internet Information Service Manager, right-click the webpage or directory to be redirected, select "redirect to URL", and enter the address of the target page in the dialog box, remember to select"Permanent resource redirectionClick "application.
Note: remind you again that you must select "permanent resource redirection ".
7. Apache server implements 301 redirection
The method for implementing 301 redirection on the Apache server is outlined in the previousArticleAs mentioned in, you only need to add the following rules to the. htaccess file:
Redirect/old directory/address of the new document with the old document name |
It may also be:
Redirect/olddirectory http://www.newsite.com/newdirectory |
Note: Pay attention to the writing format. The first is to direct a document under the same domain name to the new directory address, and the second is to define the old directory to the new directory of the new domain name, for more information, see. for more information about htaccess applications, see how to use htaccess files.
The above seven methods are often used in website management and optimization.301 redirection MethodOf course, you may also encounter a very different situation. At this time, you need to adjust the command rules as needed to adapt to different needs.