<td>last|L</td>
<td>Stop the rewriting process immediately and don't apply any
more rules. Especially note caveats for per-directory and
- .htaccess context. <em><a
+ .htaccess context (see also the END flag). <em><a
href="../rewrite/flags.html#flag_l">details ...</a></em></td>
</tr>
<tr>
href="../rewrite/flags.html#flag_r">details ...</a></em>
</td>
</tr>
+ <tr>
+ <td>END</td>
+ <td>Stop the rewriting process immediately and don't apply any
+ more rules. Also prevents further execution of rewrite rules
+ in per-directory and .htaccess context. (Available in 2.3.9 and later)
+ <em><a href="../rewrite/flags.html#flag_l">details ...</a></em></td>
+ </tr>
<tr>
<td>skip|S=<em>num</em></td>
<td>Tells the rewriting engine to skip the next <em>num</em>
count solely on the [L] flag to terminate execution of a series of
rules, as shown below.</p>
+<p> An alternative flag, [END], can be used to terminate not only the
+current round of rewrite processing but prevent any subsequent
+rewrite processing from occuring in per-directory (htaccess)
+context. This does not apply to new requests resulting from external
+redirects.</p>
+
<p>The example given here will rewrite any request to
<code>index.php</code>, giving the original request as a query string
argument to <code>index.php</code>, however, the <directive
static ap_dbd_t *(*dbd_acquire)(request_rec*) = NULL;
static void (*dbd_prepare)(server_rec*, const char*, const char*) = NULL;
+static const char* really_last_key = "rewrite_really_last";
/*
* in order to improve performance on running production systems, you
#define RULEFLAG_ESCAPEBACKREF 1<<14
#define RULEFLAG_DISCARDPATHINFO 1<<15
#define RULEFLAG_QSDISCARD 1<<16
+#define RULEFLAG_END 1<<17
/* return code of the rewrite rule
* the result may be escaped - or not
cp->next = NULL;
cp->data = val;
}
+ else if (!strcasecmp(key, "nd")) { /* end */
+ cfg->flags |= RULEFLAG_END;
+ }
else {
++error;
}
break;
}
+ if (p->flags & RULEFLAG_END) {
+ rewritelog((r, 8, perdir, "Rule has END flag, no further rewriting for this request"));
+ apr_pool_userdata_set("1", really_last_key, apr_pool_cleanup_null, r->pool);
+ break;
+ }
/*
* Stop processing also on proxy pass-through and
* last-rule and new-round flags.
const char *thisurl;
unsigned int port;
int rulestatus;
+ void *skipdata;
/*
* retrieve the config structures
return DECLINED;
}
+ /* END flag was used as a RewriteRule flag on this request */
+ apr_pool_userdata_get(&skipdata, really_last_key, r->pool);
+ if (skipdata != NULL) {
+ rewritelog((r, 8, NULL, "Declining, no further rewriting due to END flag"));
+ return DECLINED;
+ }
+
/*
* add the SCRIPT_URL variable to the env. this is a bit complicated
* due to the fact that apache uses subrequests and internal redirects
int n;
char *ofilename;
int is_proxyreq;
+ void *skipdata;
dconf = (rewrite_perdir_conf *)ap_get_module_config(r->per_dir_config,
&rewrite_module);
return DECLINED;
}
+ /* END flag was used as a RewriteRule flag on this request */
+ apr_pool_userdata_get(&skipdata, really_last_key, r->pool);
+ if (skipdata != NULL) {
+ rewritelog((r, 8, dconf->directory, "Declining, no further rewriting due to END flag"));
+ return DECLINED;
+ }
+
/*
* Do the Options check after engine check, so
* the user is able to explicitely turn RewriteEngine Off.