Reputation: 1
I have a page which is returned by https://myserver.com/login?z=XXXXXX
XXXXXX is a 6-character string such as ABC123.
I would like Apache to return an 403: Forbidden error response if file %{DOCUMENT_ROOT}/z/XXXXXX doesn't exist.
I have tried several approaches such as:
<If "%{QUERY_STRING} =~ /z=(......)/">
RewriteCond %{DOCUMENT_ROOT}/z/$1 !-f
RewriteRule . - [F,END]
</If>
without success. I suspect that the above doesn't work because the $1 reference in the second line is not picking up the bracketed expression in the first line.
It returns a Forbidden error if the query string matches /z=(......)/ regardless of whether {DOCUMENT_ROOT}/z/$1 exists - ie it is saying that %{DOCUMENT_ROOT}/z/$1 doesn't exist, even if the file implied by the query string does exist.
The If is working: it only returns Forbidden if the query string matches z=(......)
So how can I do this?
Upvotes: 0
Views: 8