YII how to handle custom 404 error page along with other error pages

前端 未结 4 2322
执笔经年
执笔经年 2021-02-20 05:05

I want to display 404 error page for that i have made error404.php file in my protected/view/system folder.

By default i have Sitecontroller and it contained error acti

4条回答
  •  名媛妹妹
    2021-02-20 05:41

    Can't you do this with .htaccess? Personally I create an "errors" folder with all the html php files that holds the error messages and modify .htaccess to call those pages while coming across the error.

    Links:

    http://www.javascriptkit.com/howto/htaccess2.shtml

    http://www.addedbytes.com/for-beginners/error-documents-for-beginners/

    Examples:

    Create a .htaccess file in the directory you want the error pages to be called and in the text file, write the following line:

    ErrorDocument 404     /404.html
    

    assuming there is a page called 404.html in the same directory, when a 404 page not found error is genrated, the 404.html page will be called.

    The same works with other error codes:

    ErrorDocument 500     /500error.html
    

    assuming a 500 error was created and a 500error.html file exists in the same directory.

提交回复
热议问题