How to customize 404 and 503 pages through. htaccess
SEO website optimization404, 503 Mistakenly believe mostBeijing website constructionThe webmaster friends are very familiar with it. After the website has just been built, we usually make a 404 and 503 error page.So how does this work?My friends who are familiar with me will surely remember my article "A detailed explanation of Apache server 301 redirection" written a few days ago,Beijing website productionThat is to say, 301 redirection function is realized through. htaccess.So this time, the author also uses. htaccess to achieve.First of all, what are the 404 and 503 errors.
404:404 The return code means "NOT FOUND". The search engine will think that the web page has failed, and it will usually be deleted from the search results. In the short term, the spider will not crawl the url if it finds it again.
The 503:503 return code means "Service Unavailable". Search engines will think that the webpage is temporarily inaccessible, which usually happens when the website is temporarily closed and bandwidth is limited.For the 503 returned from the webpage, the spider will not delete the url directly, but will visit it again in a short time.If the web page has been restored at that time, it will be crawled normally;If you continue to return to 503, you will visit it several times in a short time.However, if the page returns 503 for a long time, the URL will still be considered as an invalid link by the search engine and deleted from the search results.
1、 The method to customize the 404 error page through. htaccess is as follows.First, create a new notepad locally, and enter the following code for the body content:
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
ErrorDocument 404 /404.html
order deny,allow
Then save the file, rename it ". htaccess" and upload it to the location defined in the code.For example, the path of 404.html page in the above code is the root directory.One thing to note here is that files in the general local environment do not support the naming of ". htaccess", so you can change the file name after uploading the file via FTP.
2、 The method of customizing 503 error pages through. htaccess.Similar to the first one, create a new notepad and enter the following code ",
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
ErrorDocument 503 /503.html
order deny,allow
Then save the corresponding path uploaded to the website via FTP.
Finally, give the novice webmasters a suggestion.When the website is temporarily closed, do not return to 404 immediately. It is better to use 503 status.503 can tell the search engine spider that the page is temporarily inaccessible. Please try again after a while.In addition, if spiders have too much pressure to crawl your site, try not to use 404. It is also recommended to return 503.In this way, the search engine spider will try to crawl the link again after a period of time. If the site is free at that time, it will be successfully crawled.