404 mistake, do you know what he means?

Source: Internet
Author: User
Keywords We
Tags .url address address bar aspx browser button change click

Absrtact: We often say 404 mistakes, do you know what he means? 404 is actually a status code contained in the HTTP header, indicating that the HTTP request failed. So what are the common status codes? What's the relationship between these status codes and SEO?

We often say "404 mistakes", do you know what he means? 404 is actually a "status code" contained in the HTTP header, indicating that the HTTP request failed. So what are the common status codes? What is the relationship between these status codes and SEO?

Each time a user agent (which is understood to be IE and Firefox) requests a URL address to a Web site, the server responds with a reply that includes two parts: the HTTP header and the requested content. But only from the browser we usually see the content but not the header information. So we need some browser plug-ins to observe them. Personally, ie I use webdeveloper; Firefox I use fiddler. Interested friends can download their own online, two are quite popular.

For SEO, the status codes we need to know are:

Redirect: 301 and 302

Deleted: 404

Server Error: 500

We will explain in turn, 302 first. 302 There is a very common prototype in asp.net: Response.Redirect (), see Code:

protected void Button1_Click (object sender, EventArgs e)
{
Response.Redirect ("~/target.aspx");
Server.Transfer ("~/target.aspx");
}

Source.aspx page on the previous Button,click event code for Response.Redirect (~/target.aspx), click on the Source.aspx page button to view the page corresponding to the status code, the result is 302. (The following figure, I am using the Web Development, do not know why after the Enable log, can not go to the target page again?) The students know the reason, please advise pleaes)

But you can see the details and you can see the 302 impact, response indicates the URL to turn to.

The process of round-trip between client/server is actually this:

1. Click button, generate a postback, the return of the target page is still source.aspx, so the request is still processed by the Source.aspx page, so as to enter the Source.aspx page click event;

2. In the Click event, what Response.Redirect (~/target.aspx) does is actually:

2.1 Change the status code of the HTTP header in the reply to 302;

2.1 Indicates that 302 points to the page is target.aspx;

3. After the browser (user agent) receives the header information of the reply,

3.1 Change URL address bar address to target.aspx;

3.2 Making a request to target.aspx

Also known as Response.Redirect () is Server.Transfer (). But using Server.Transfer, you will find that the page corresponding to the status code is 200, and the Address bar URL will not change, is still source.aspx! This is because the Server.Transfer is completely on the server side of the jump. So one popular thing that I don't think is right is that you should use Server.Transfer () instead of Response.Redirect () to improve performance. As you get the Server.Transfer () performance boost, you should weigh the increase in performance, and the resulting cost. It is difficult to give an answer directly, depending on the situation to be judged. But I tend to try not to use Server.Transfer (), because: 1. Performance is not improved, the savings are actually header information round-trip; 2. Clear URL for the end user, or development and debugging, have a very important role.

OK, understand 302,301 also good to do. 302 means that emphasis orientation is temporary, and 301 is permanent redirection.

As far as SEO is concerned, in order to extend the link value and eliminate duplicate content, we may use 301 in the following situations:

1. Domain name replacement;

2. Multiple domain name mapping, such as www.freeflying.com and www.freeflying.cn, two domain names are actually pointing to the same site, which will cause a lot of duplication of content, the ranking of the site is unfavorable.

3. Clear the default index page repeat problem: for example, when we enter www.freeflying.com/article/, if the setting in IIS, will point to www.freeflying.com/article/Default.aspx

4. Other "different domain name same content" duplication problem, typical is URL rewrite, www.freeflying.com/article/321.html and www.freeflying.com/article.aspx? Id=321 point to is actually the same page content.

For 404, the most intuitive understanding is that the page does not exist. This is well understood if the site is purely static, but when the site is dynamic, such as www.freeflying.com/article/321.html (mapped to www.freeflying.com/article.aspx?). id=321), although Id=321 's article has been deleted, or does not exist, but article.aspx this page is always present, so the status code of the HTTP header will not be 404, but 200, indicating that the request succeeded.

We assume that a website has id=321/342/6739 ... The article has been deleted, but the spider does not know, it will still be crawled, as a result it found that these different URLs are actually all the same page. It treats it as a repeating page.

500 means that there are exceptions within the program, such as 3/0, and the code is as follows:

protected void Button1_Click (object sender, EventArgs e)

{

int I, J;

i = 8;

j = 0;

This. Label1.Text = (i/j). ToString ();

}

If the search engine receives a 500 status code, the search engine will understand that the program is only a temporary error, it will continue to crawl later, to see if the problem has been resolved, this does not give the site too much problem-as long as you can recover as soon as possible. However, asp.net with a custom error Web.config configuration, will let us inadvertently "mistakes." The reason is similar to the 404 change 200 mentioned above, When turning to the custom error.aspx, the spider obtains is the successful link error.aspx 200 code, therefore the spider will think the error originpage.aspx normal display content is the error.aspx content. The originpage.aspx of different URL parameters will be considered by spiders as different URLs, so spiders will think that all URLs are duplicated-the consequences are very serious.

Well, recognizing the seriousness of the problem, we look at the solution to the problem, too simple, hehe

protected void Page_Load (object sender, EventArgs e)

{

If you want the search engine to know that this URL will no longer be used

Response.statuscode = 404;

If you want to tell the search engine that the URL just appears to be a temporary glitch

Response.statuscode = 500;

If you want to permanently redirect the page

Response.statuscode = 301;

Response.redirectlocation = @ "\website1\target.aspx";

}

Free flying

Original address: http://www.cnblogs.com/freeflying/archive/2010/02/24/1672308.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.