</section>
+<section id="flag_qsl"><title>QSL|qslast</title>
+<p>
+By default, the first (left-most) question mark in the substitution
+delimits the path from the query string. Using the [QSL] flag instructs
+<directive module="mod_rewrite">RewriteRule</directive> to instead split
+the two components using the last (right-most) question mark. </p>
+
+<p>
+This is useful when mapping to files that have literal question marks in
+their filename. If no query string is used in the substitution,
+a question mark can be appended to it in combination with this flag. </p>
+
+<p> This flag is available in version 2.5.0 and later.</p>
+
+</section>
+
+
<section id="flag_r"><title>R|redirect</title>
<p>
Use of the [R] flag causes a HTTP redirect to be issued to the browser.
#define RULEFLAG_QSDISCARD (1<<16)
#define RULEFLAG_END (1<<17)
#define RULEFLAG_ESCAPENOPLUS (1<<18)
+#define RULEFLAG_QSLAST (1<<19)
/* return code of the rewrite rule
* the result may be escaped - or not
* split out a QUERY_STRING part from
* the current URI string
*/
-static void splitout_queryargs(request_rec *r, int qsappend, int qsdiscard)
+static void splitout_queryargs(request_rec *r, int qsappend, int qsdiscard,
+ int qslast)
{
char *q;
int split;
rewritelog((r, 2, NULL, "discarding query string"));
}
- q = ap_strchr(r->filename, '?');
+ q = qslast ? ap_strrchr(r->filename, '?') : ap_strchr(r->filename, '?');
+
if (q != NULL) {
char *olduri;
apr_size_t len;
olduri = apr_pstrdup(r->pool, r->filename);
*q++ = '\0';
if (qsappend) {
- r->args = apr_pstrcat(r->pool, q, "&", r->args, NULL);
+ if (*q) {
+ r->args = apr_pstrcat(r->pool, q, "&" , r->args, NULL);
+ }
}
else {
r->args = apr_pstrdup(r->pool, q);
} else if ( !strcasecmp(key, "SD")
|| !strcasecmp(key, "sdiscard") ) { /* qsdiscard */
cfg->flags |= RULEFLAG_QSDISCARD;
+ } else if ( !strcasecmp(key, "SL")
+ || !strcasecmp(key, "slast") ) { /* qslast */
+ cfg->flags |= RULEFLAG_QSLAST;
}
else {
++error;
r->path_info = NULL;
}
- splitout_queryargs(r, p->flags & RULEFLAG_QSAPPEND, p->flags & RULEFLAG_QSDISCARD);
+ splitout_queryargs(r, p->flags & RULEFLAG_QSAPPEND,
+ p->flags & RULEFLAG_QSDISCARD,
+ p->flags & RULEFLAG_QSLAST);
/* Add the previously stripped per-directory location prefix, unless
* (1) it's an absolute URL path and