From: Stefan Fritsch Date: Thu, 30 Dec 2010 12:34:19 +0000 (+0000) Subject: Make the REQUEST_SCHEME variable available to scripts and mod_rewrite X-Git-Tag: 2.3.11~304 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c6979ede6d856855c854119673ec40f40a7c0c7;p=apache Make the REQUEST_SCHEME variable available to scripts and mod_rewrite git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1053872 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index e6099e76f9..c682177109 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.11 + *) core, mod_rewrite: Make the REQUEST_SCHEME variable available to + scripts and mod_rewrite. [Stefan Fritsch] + *) mod_rewrite: Allow to use arbitrary boolean expressions (ap_expr) in RewriteCond. [Stefan Fritsch] diff --git a/docs/manual/mod/mod_rewrite.html.en b/docs/manual/mod/mod_rewrite.html.en index 800dcd8c69..dac6a11f58 100644 --- a/docs/manual/mod/mod_rewrite.html.en +++ b/docs/manual/mod/mod_rewrite.html.en @@ -263,6 +263,7 @@ RewriteRule ^index\.html$ newsite.html REQUEST_FILENAME
IS_SUBREQ
HTTPS
+ REQUEST_SCHEME
@@ -325,6 +326,12 @@ RewriteRule ^index\.html$ newsite.html can be safely used regardless of whether or not mod_ssl is loaded). +
REQUEST_SCHEME
+ +
Will contain the scheme of the request (ususally + "http" or "https"). This value can be influenced with + ServerName.
+ diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index ba0060a4c6..f13fe66189 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -436,6 +436,7 @@ RewriteRule ^index\.html$ newsite.html REQUEST_FILENAME
IS_SUBREQ
HTTPS
+ REQUEST_SCHEME
@@ -498,6 +499,12 @@ RewriteRule ^index\.html$ newsite.html can be safely used regardless of whether or not mod_ssl is loaded). +
REQUEST_SCHEME
+ +
Will contain the scheme of the request (ususally + "http" or "https"). This value can be influenced with + ServerName.
+ diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 83ef53c386..73f0a882f2 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -2089,9 +2089,12 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx) if (*var == 'H' && !strcmp(var, "HTTP_FORWARDED")) { result = lookup_header("Forwarded", ctx); } - else if (!strcmp(var, "REQUEST_METHOD")) { + else if (var[8] == 'M' && !strcmp(var, "REQUEST_METHOD")) { result = r->method; } + else if (!strcmp(var, "REQUEST_SCHEME")) { + result = ap_http_scheme(r); + } break; case 15: diff --git a/server/util_script.c b/server/util_script.c index d8c3f1f297..2d070816f0 100644 --- a/server/util_script.c +++ b/server/util_script.c @@ -337,6 +337,7 @@ AP_DECLARE(void) ap_add_cgi_vars(request_rec *r) apr_table_setn(e, "GATEWAY_INTERFACE", "CGI/1.1"); apr_table_setn(e, "SERVER_PROTOCOL", r->protocol); apr_table_setn(e, "REQUEST_METHOD", r->method); + apr_table_setn(e, "REQUEST_SCHEME", ap_http_scheme(r)); apr_table_setn(e, "QUERY_STRING", r->args ? r->args : ""); apr_table_setn(e, "REQUEST_URI", original_uri(r));