How to block access to certain file extension in Tomcat

Posted on 2011-05-01
Last Modified: 2012-05-11
Hi,  if I have a test.txt file in the tomcat web directory and can be accessed via  

Where and how do i change the tomcat config to block access to all files with *.txt extension, so when user hits the url  they get an access denied or some kind of error.  

Thank you.
Question by:gagaliya
    1 Comment
    LVL 5

    Accepted Solution

    You can find a URL Rewrite Filter here: (manual at

    Add a url-pattern for \.txt$  and set the response header to 'HTTP/x.y 404 Not Found' (x.y being the HTTP-version from the request), or rewrite to a non-existing URL for automatic 404 (quick & dirty hack).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
    In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now