Home  >  Article  >  Backend Development  >  Detailed explanation of 301 usage and errors

Detailed explanation of 301 usage and errors

WBOY
WBOYOriginal
2016-07-25 08:57:361412browse
  1. Options +FollowSymLinks
  2. RewriteEngine on
  3. RewriteCond %{HTTP_HOST} ^domain.com [NC]
  4. RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
Copy code

If you are using a Windows host, you should make 301 redirect settings in the control panel. Editor's Choice: Introduction to php pseudo-static URL REWRITE rewriting rules php URL rewrite path rewriting example

Supplement: Answering Stone King’s question in the URL standardization comment may be helpful to everyone:

As far as I know, HTML cannot do 301 redirects. You can only do JS or META REFRESH in HTML, but not 301 redirects. As soon as the HTML is read, a 200 OK status code is returned.

If your page is ASP or PHP, you can also do a 301 redirect: ASP:

  1. <%@ Language=VBScript %>
  2. <%
  3. Response.Status=”301 Moved Permanently” Response.AddHeader “Location”, ” http://www.domain.com”
  4. > ;
Copy code

PHP:

  1. Header( “HTTP/1.1 301 Moved Permanently” );
  2. Header( “Location: http://www.domain.com” );
  3. ?>
Copy code

Also, The DOThtaccess file is just an ordinary text file. You use Notepad to create this file, put the instructions, and save it in the root directory of your account. No modifications to Apache are required.

Question: How long does it take for search engines to process a web page after a 301 redirect?

After the web page is redirected with 301, will the page with the old domain name indexed by the original search engine be forwarded to the new domain name it is directed to? What will happen to pages with old domain names indexed by search engines, for example? Will the content in the old domain name be transferred to the new domain name after site:www.xxx.com? How long will it take?

A: If your old URL points to your new site using an HTTP 301 (permanent) redirect, search engines will automatically learn of the new URL as they roam and update it automatically within six to eight weeks.

301 redirect can promote search engine optimization effect

From the perspective of search engine optimization, 301 redirection is the most feasible way to redirect URLs. When the domain name of a website changes, the search engine will only index the new URL, and at the same time, it will transfer all the original external links under the old address to the new address, so that the ranking of the website will not be affected due to the URL change. No impact at all. Similarly, when using the 301 permanent redirect command to point multiple domain names to the main domain of the website, it will not have any negative impact on the ranking of the website.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn