Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 want to deliberately throw an arbitrary error. Something appropriate between the <LocationMatch>...</LocationMatch> directorives. e.g.:

<LocationMatch "^/myurl/.+">
    ThrowError 503

<LocationMatch "^/anotherurl/.+">
    ThrowError 504

<LocationMatch "^/safeurl/">
    # not throwing an error from this path
    Options +Indexes

What can I use instead of ThrowError 503? I want to force the server to tell the user whatever error code I choose (e.g. 404, 403, 501, etc) as a means of testing my rules. Worst case I'd like a message written to the error_log if I cannot actually throw an error at the browser.

I'm aware I could possibly use mod_rewrite to perform a RewriteRule .* - [R=503,L] however I want to just use the core modules (I do not have mod_rewrite compiled into my Apache).

Update: have discovered I can say RedirectMatch 410 . which will report a "Gone" message to the user as one potential solution.

share|improve this question
up vote 2 down vote accepted

As you mentioned yourself, the Redirect directive (not necesssary for RedirectMatch, I think?) which is part of mod_alias should do the trick.

From the docs:

Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the URL argument must be present, otherwise it must be omitted. Note that the status must be known to the Apache code (see the function send_error_response in http_protocol.c).

Example: Redirect 303 /three


I don't know much about C code, but from a quick look at http_protocol.c, these are your options:

100 Continue
101 Switching Protocols
102 Processing

200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status

300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
306 unused
307 Temporary Redirect

400 Bad Request
401 Authorization Required
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Time-out
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Large
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
418 unused
419 unused
420 unused
421 unused
422 Unprocessable Entity
423 Locked
424 Failed Dependency
425 No code
426 Upgrade Required

500 Internal Server Error
501 Method Not Implemented
502 Bad Gateway
503 Service Temporarily Unavailable
504 Gateway Time-out
505 HTTP Version Not Supported
506 Variant Also Negotiates
507 Insufficient Storage
508 unused
509 unused
510 Not Extended

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.