thinkphp 3.2.x Changing the exception head to 503

Source: Internet
Author: User

If the program has an exception, the thinkphp default is to throw 404 headers.


ThinkPHP3.2.3 Related code:

#/thinkphp/library/think/think.class.php    /**     * Custom exception handling     * @access public     * @param mixed $e Exception Object     */    static public Function appexception ($e) {        $error = array ();        $error [' message ']   =   $e->getmessage ();        $trace              =   $e->gettrace ();        if (' E ' = = $trace [0][' function ']) {            $error [' file ']  =   $trace [0][' file '];            $error [' line ']  =   $trace [0][' line '];        } else{            $error [' file ']  =   $e->getfile ();            $error [' line ']  =   $e->getline ();        }        $error [' trace ']     =   $e->gettraceasstring ();        Log::record ($error [' message '],log::err);        Send 404 Message        header (' http/1.1 404 Not Found ');        Header (' status:404 not Found ');        Self::halt ($error);    }


404 is not found, the exception is thrown 404 HTT head, in fact, is wrong.

should be modified to 503 the most appropriate, modify the method, the header section is modified as follows:

        Header (' http/1.1 503 Service unavailable ');        Header (' status:503 Service unavailable ');



Related:"Baidu search engine Working principle"
[Url]http://zhanzhang.baidu.com/college/courseinfo?id=144[/url]

2, commonly used crawl return code        simple introduction of several Baidu support return code:        1) The most common 404 for "not FOUND", that the page has been invalidated, will usually be deleted in the library, and in the short term if the spider again found that the URL will not crawl;        2) 503 on behalf of "Service unavailable", that the Web page is temporarily inaccessible, usually the temporary closure of the site, limited bandwidth and so on will produce this situation. For the Web page returned 503 status code, Baidu Spider will not be directly deleted this URL, while the short-term will be repeated visits several times, if the page has been restored, the normal crawl, if you continue to return 503, then this URL will still be considered as a broken link, deleted from the library.        3) 403 on behalf of "Forbidden", that the page is currently prohibited access. If the new Url,spider temporarily do not crawl, the short-term will also be repeated visits several times, if it is included in the URL, will not be deleted directly, the same repeated visits several times in the short term. If the Web page is accessed normally, the crawl is normal, and if access is still disabled, the URL is considered a broken link and deleted from the library.        4) 301 represents "Moved permanently", which is considered to redirect the Web page to the new URL. When encountered site migration, domain name replacement, site revision, we recommend the use of 301 return code, while using Webmaster Platform website revision tools to reduce the revision of the loss caused by the website traffic.


other Frameworks
With CodeIgniter, an exception occurs when the 500 header is thrown. Including the other frames are 5xx heads. (original by [email protected], reprint please famous source, Welcome to Exchange)



thinkphp 3.2.x Changing the exception head to 503

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.