How to do 301 redirects on website revision pages

My website was built with the wordpress system before. Later, because of spam comments, security and functional limitations, I switched to the cicada system and made a new one. The theme interface is still the same as the previous WP theme. But after the new site went online, the problem came, because the URL design of the two site building systems was different, which made all the pages of the old site except the home page inaccessible. Re-editing and publishing with the new address is not conducive to SEO optimization. So in the end I thought of 301 jump.

 

What is a 301 redirect

301 redirect (or 301 redirect) is a type of status code in the header part of the HTTP data stream returned by the service when a user or a search engine spider sends an access request to the website server, indicating that this website is permanently transferred to another address.

 

The difference between 301 and 302

You may have also heard of 302 redirects. Both 301 and 302 are HTTP status codes, which both represent a transfer of a URL. The difference is that 301 is a permanent redirect, while 302 is a temporary redirect. . From an SEO perspective, we highly recommend the use of 301 redirects.


Under what scenarios do I do a 301 jump?

 

1. The redundant name points to the same site. For example, for two addresses with www and without www, we usually point the root domain name without www to the secondary domain name of www. Because in the eyes of search engines, these are two different sites.

2. The website has been revised and the address has changed. Just like the situation I encountered, it is necessary to redirect the previous URL 301 to the new URL.

 

How to do a 301 jump

I take my own website as an example. The web server uses Apache. For example, I want to change the previous URL www.domain.com/100.html to the new URL wwww.domain.com/life-100.html, which can be in the apache configuration file Add the following code:

 

Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/100.html$ /life-100.html[NC,L,R=301]

 

Save and restart the Apache service. At this point, when we visit the www.domain.com/100.html address in the browser, the page content will jump to www.domain.com/life-100.html.

 

For another example, it is common to jump from the root domain name without www to the domain name with www. The method is the same as above, and the code is entered below:

 

Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

 

Don't forget that you need to restart the WEB service to take effect.

 

summary

This article shares with you the relevant knowledge of 301 redirection and how to perform 301 redirection operation on website pages. If you have any questions or other methods of operation, welcome to share and communicate with you, we will learn together and make progress together.

For more technical articles, please pay attention to the WeChat public account

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326489181&siteId=291194637