In the ecshop system, for example, if you modify the ID in the address of the product details page to a non-existent product ID, ecshop will automatically jump to the home page.
Ecshop is doing very poorly in this regard, and even many websites are not indexed by search engines. The most template provides the analysis of this ecshop tutorial as follows:
1. Analysis: ecshop program file category. PHP and goods. the following code exists in multiple pages such as PHP: ecs_header ("Location :. /\ n "); exit; the Code above indicates that if you cannot find the category or product under the current ID, you will be redirected to the homepage of the website. In this way, the returned HTTP code will be 302, indicating that the page information is temporarily transferred. This type of Jump code can easily cause search engine blocking, so we need to make a 404 optimization.
2. Modify the files involved:
Article. php, article_cat.php, brand. php, category. php, comment. php, goods. php, topic. php
3. Modification Method: replace
Ecs_header ("Location:./\ n ");
Change all
Ecs_header ("HTTP/1.0 404 Not Found ");
$ Smarty-> display('404.html ');
Add a 404.html file to the website file at the same time
In ecshop, The 404 error page is set as follows:
1. If the webpage content cannot be accessed due to a path change, you can define a 404 error in IIS to point to a dynamic page, and use 301 to redirect permanently to a new address in the page, in this case, the server returns the 301 status code.
2. Set 404 to point to a designed HTML file. The 404 status code returned by the page is displayed. Currently, IDC providers basically provide the 404 setting function, which allows you to directly Upload File Settings. How to Set in IIS: open IIS manager --> click the properties of the website for which you want to set custom 404 --> click custom error options --> Select page 404 --> select and open edit Attributes --> set to URL --> enter "/err404.html" in the URL --> return the URL and upload the err404.html page to the root directory of the website. In "Message Type", you must select "file" or "Default Value" instead of "url". Otherwise, the "200" status code is returned.
3. 404 points to a dynamic page, such as error. ASP. If it is not set in the page, only the HTML code of the prompt is returned, which will result in the 200 status code returned on the page. This is incorrect. After the prompt content is displayed, add statement:Response. Status = "404 Not found"In this way, the page will return a 404 status code.
4. Set the 404 error page in Apache. Setting the 404 error page for apacheserver is simple. You only need to add the following content to the. htaccess file,Errordocument 404/notfound. php