I want to deliberately throw an arbitrary error. Something appropriate between the <LocationMatch>
...</LocationMatch>
directorives. e.g.:
<LocationMatch "^/myurl/.+">
ThrowError 503
</LocationMatch>
<LocationMatch "^/anotherurl/.+">
ThrowError 504
</LocationMatch>
<LocationMatch "^/safeurl/">
# not throwing an error from this path
Options +Indexes
</LocationMatch>
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.
As you mentioned yourself, the
Redirect
directive (not necesssary forRedirectMatch
, I think?) which is part of mod_alias should do the trick.From the docs:
Example:
Redirect 303 /three http://example.com/other
Edit:
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