aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_rewrite_handler.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-04-25 20:13:21 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-04-25 20:13:21 +0000
commit3f4685f3ded30199ec0c61f98b016f5880330422 (patch)
tree9b633e6681f3b02123700dea850ba0083eb4d6cb /src/http/modules/ngx_http_rewrite_handler.c
parenta040f00167fa64e0bd5ea85f3c0551358e0ee544 (diff)
downloadnginx-3f4685f3ded30199ec0c61f98b016f5880330422.tar.gz
nginx-3f4685f3ded30199ec0c61f98b016f5880330422.zip
nginx-0.0.3-2004-04-26-00:13:21 import
Diffstat (limited to 'src/http/modules/ngx_http_rewrite_handler.c')
-rw-r--r--src/http/modules/ngx_http_rewrite_handler.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index 8a645e082..7d36b131a 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -26,6 +26,7 @@ typedef struct {
ngx_str_t re_name;
ngx_str_t s_name;
+ ngx_uint_t status;
unsigned last:1;
} ngx_http_rewrite_rule_t;
@@ -123,7 +124,8 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
if (rc == NGX_DECLINED) {
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
- "\"%s\" does not match", rule[i].re_name.data);
+ "\"%s\" does not match \"%s\"",
+ rule[i].re_name.data, r->uri.data);
}
continue;
@@ -139,7 +141,12 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
- "\"%s\" matches", rule[i].re_name.data);
+ "\"%s\" matches \"%s\"",
+ rule[i].re_name.data, r->uri.data);
+ }
+
+ if (rule[i].status) {
+ return rule[i].status;
}
uri.len = rule[i].size;
@@ -247,6 +254,8 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
rule->msize = 0;
rule->size = 0;
+ rule->status = 0;
+ rule->last = 0;
value = cf->args->elts;
@@ -264,6 +273,19 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
rule->re_name = value[1];
rule->s_name = value[2];
+ if (ngx_strcasecmp(value[2].data, "forbidden:") == 0) {
+
+ if (cf->args->nelts == 3) {
+ rule->status = NGX_HTTP_FORBIDDEN;
+ rule->last = 1;
+ return NGX_CONF_OK;
+ }
+
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid parameter \"%s\"", value[3].data);
+ return NGX_CONF_ERROR;
+ }
+
for (i = 0; i < value[2].len; /* void */) {
if (!(op = ngx_push_array(&rule->ops))) {