data to the query string via a rewrite rule. This rule has no net effect
unless your substitution explicitly provides a new query string.</dd>
+ <dt>'<code>qsdiscard|QSD</code>'
+ (query string discard)</dt><dd>
+ Discards any query string attached to the incoming URI. Without
+ this flag, the query string will be automatically copied from
+ the request URI to the rewritten URL. Note, however, that if you
+ provide a query string on your target URI, that one will be used
+ instead.</dd>
+
<dt>'<code>redirect|R</code>
[=<em>code</em>]' (force <a id="redirect" name="redirect">redirect</a>)</dt><dd>
<p>Prefix <em>Substitution</em> with
data to the query string via a rewrite rule. This rule has no net effect
unless your substitution explicitly provides a new query string.</dd>
+ <dt>'<code>qsdiscard|QSD</code>'
+ (query string discard)</dt><dd>
+ Discards any query string attached to the incoming URI. Without
+ this flag, the query string will be automatically copied from
+ the request URI to the rewritten URL. Note, however, that if you
+ provide a query string on your target URI, that one will be used
+ instead.</dd>
+
<dt>'<code>redirect|R</code>
[=<em>code</em>]' (force <a id="redirect"
name="redirect">redirect</a>)</dt><dd>
</p>
+<h3><a name="flag_qsd" id="flag_qsd">QSD|qsdiscard</a></h3>
+<p>
+When the requested URI contains a query string, and the target URI does
+not, the default behavior of <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> is to copy that query
+string to the target URI. Using the [QSD] flag causes the query string
+to be discarded.
+</p>
+
+<p>
+Using [QSD] and [QSA] together will result in [QSD] taking preference.
+</p>
+
+<p>
+If the target URI has a query string, the default behavior will be
+observed - that is, the original query string will be discarded and
+replaced with the query string in the <code>RewriteRule</code> target
+URI.
+</p>
+
+
+
<h3><a name="flag_r" id="flag_r">R|redirect</a></h3>
<p>
Use of the [R] flag causes a HTTP redirect to be issued to the browser.
</p>
</section>
+<section id="flag_qsd"><title>QSD|qsdiscard</title>
+<p>
+When the requested URI contains a query string, and the target URI does
+not, the default behavior of <directive
+module="mod_rewrite">RewriteRule</directive> is to copy that query
+string to the target URI. Using the [QSD] flag causes the query string
+to be discarded.
+</p>
+
+<p>
+Using [QSD] and [QSA] together will result in [QSD] taking preference.
+</p>
+
+<p>
+If the target URI has a query string, the default behavior will be
+observed - that is, the original query string will be discarded and
+replaced with the query string in the <code>RewriteRule</code> target
+URI.
+</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_STATUS 1<<13
#define RULEFLAG_ESCAPEBACKREF 1<<14
#define RULEFLAG_DISCARDPATHINFO 1<<15
+#define RULEFLAG_QSDISCARD 1<<16
/* 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)
+static void splitout_queryargs(request_rec *r, int qsappend, int qsdiscard)
{
char *q;
return;
}
+ if ( qsdiscard ) {
+ r->args = NULL; /* Discard query string */
+ rewritelog((r, 2, NULL, "discarding query string"));
+ }
+
q = ap_strchr(r->filename, '?');
if (q != NULL) {
char *olduri;
if ( !strcasecmp(key, "SA")
|| !strcasecmp(key, "sappend")) { /* qsappend */
cfg->flags |= RULEFLAG_QSAPPEND;
+ } else if ( !strcasecmp(key, "SD")
+ || !strcasecmp(key, "sdiscard") ) { /* qsdiscard */
+ cfg->flags |= RULEFLAG_QSDISCARD;
}
else {
++error;
r->path_info = NULL;
}
- splitout_queryargs(r, p->flags & RULEFLAG_QSAPPEND);
+ splitout_queryargs(r, p->flags & RULEFLAG_QSAPPEND, p->flags & RULEFLAG_QSDISCARD);
/* Add the previously stripped per-directory location prefix, unless
* (1) it's an absolute URL path and