Tomcat definition 404 page, customizing the Tomcat default access page

Source: Internet
Author: User
Custom 404 Pages

Recently, in dealing with security vulnerabilities, found that the root, manager, example and so on under Tomcat have no security mechanism, so it was deleted, but access to the Localhost:8080/example test will be a sudden leakage of Tomcat basic information, Although the content is not many but still want to give 404 page hint, the concrete modification method is relatively simple.

Add the following code to the Conf/server.xml

<error-page> 
    <error-code>404</error-code> 
    <location>/404.html</location> 
</error-page>

Configuration is complete, but this 404 page needs to be defined by itself and where the file is placed. In fact, when the visit to localhost:8080/after the kitten remember, is the root file under the content, we do not delete the root folder, the 404.html page into the root folder can be in the test access localhost:8080/example You will find that you will jump to our custom 404.html. Customizing the default access page

Or the cat, how to access localhost:8080 doesn't appear on that cat's welcome page, likewise, in conf/ Server.xml file settings, where welcome-file in order to load, where you want to load the default page can be, base.html is the default I want to load the file replaced the original index.jsp file

 <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> welcome-file>base.html</welcome-file> </welcome-f Ile-list> 

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.