5 years ago (2015-01-06)  Algorithm language |   First to comment  15 
post score 0 times, average 0.0

 7 Ways to Implement 301 Redirection Using .htaccess Files

301 redirect is no stranger to the majority of webmasters, from website construction to directory optimization, and can't avoid making changes to the website directory. In this case, the user's favorite folder and the search engine may still keep the old address. When you open these links, you will not be able to see 404 errors on the page, resulting in a very bad user experience and losing a lot of traffic. Today, I will share with you the seven ways to implement 301 redirection.
From a search engine optimization point of view, the current 301 redirect is the most feasible way to redirect after the site directory is changed.After you use the 301 redirect to change the address, the search engine will only index the new address, and will transfer the original link under the old address to the new address. These operations will not affect the search of the website. The ranking of the engine.
The most straightforward way to implement 301 redirects is to edit .htaccess files. For more information on how to use htaccess files, check here.What the garden needs to remind you is that before operating on the .htaccess file, be sure to back up the original .htaccess file to avoid unnecessary troubles due to modification errors.

1. Redirect domain.com to www.domain.com

This kind of redirection is very common. The ultimate goal is to realize the uniqueness of the domain name, which is also what SEO must do.The implementation is to add the following rules to the .htaccess file:
code show as below:
Note: After using this 301 redirect method, when you open a URL similar to domain.com, it will automatically be directed to www.domain.com.

2. Redirect www.domain.com to domain.com

This operation is just the opposite of the above domain name display. The rules are as follows:
code show as below:
Note: With this 301 redirect, when you open a URL like www.domain.com, it will automatically be directed to domain.com.

3. Redirect olddomain.com to newdomain.com

This kind of 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 implement the redirection:
code show as below:
Note: When the user opens the old domain name, he will be automatically redirected to the site under the new domain name. The domain name display format is the format without www.

4. Redirect olddomain.com to www.newdomain.com

This operation is based on a third way of improvement, except that the display URL is shown with the type of www.
code show as below:
Note: When the user opens the old domain name, it will automatically redirect to the site under the new domain name, and the URL display format is with the format of www.

5. Redirect domain.com/file/file.php to otherdomain.com/otherfile/other.php

This kind of operation is used to change a domain name while the site directory path is also changed. The rules are as follows:
code show as below:
Note: When users visit the old domain name path, they will be redirected to the new path of the new domain name.

6. IIS server to achieve 301 redirect

The specific method is as follows: Open the internet information service manager, right-click on the web page or directory 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. "" Finally click "Apply".
Note: Remind you again, be sure to check "Permanent redirection of resources."

7.Apache server implementation 301 redirect

The way to implement 301 redirects on an Apache server was mentioned in a previous article. You only need to add the following rules to the .htaccess file:
code show as below:
It may also be:
code show as below:


Note: Be sure to write the format. The first is to direct a document to a new directory address in the same domain name, and the second is to define the old directory to the new domain name. Under contents.

The above seven methods are commonly used 301 redirect methods in the process of website management and optimization. Of course, you may also encounter different situations. At this time, you need to adjust the following rules according to your own goals. Adapt to different needs.

This article has been printed on copyright and is protected by copyright law. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click on the "sponsored author" below to reward the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/use-the-htaccess-file-seven-ways-to-achieve-301-redirect-2.html

Post comment


No Comment


Forget password?