Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there was a simple way to make apache httpd deny (403) any URLs which contain a parent .. in the path.

So far I have tried (ignoring the flase positives for simplicity)

<LocationMatch "\.\.">
Order allow,deny
Deny from all

But that didn't work. The directory has Allow from all in it. Am I on the right track or is there an easier way to do this (like there was in Fasttrack back in the 90s).

share|improve this question
up vote 1 down vote accepted

I would do it by using ModSecurity:

SecRule REQUEST_URI "../" "log,deny,msg:'Directory Traversal Attack Detected'"

Testing with some requests:

and examine the audit log, you'll see something like this:

[modsecurity] [client x.x.x.x] [domain] [302] [/20120816/20120816-1529/20120816-152911-1np2Nn8AAAEAA Aq6EU0AAAAG] [file "/etc/httpd/modsecurity.d/modsecurity_crs_10_config.conf"] [line "305"] [msg "Directory Traversal Attack Detected"] Access denied with code 403 (phase 2). Pattern match "../" at REQUEST_URI.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.