--- file_not_specified_in_diff +++ file_not_specified_in_diff @@ -1,6 +1,6 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at --- +/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at @@ -52,1 +52,0 @@ - @@ -62,0 +61,5 @@ + +typedef enum { + STRIPWWW_ON, STRIPWWW_OFF +} mva_stripwww_e; + @@ -70,0 +74,1 @@ + mva_stripwww_e stripwww; @@ -72,0 +77,1 @@ + @@ -75,1 +81,0 @@ - @@ -81,0 +86,1 @@ + conf->stripwww = STRIPWWW_OFF; @@ -107,0 +113,6 @@ + if (child->stripwww == STRIPWWW_OFF) { + conf->stripwww = parent->stripwww; + } + else { + conf->stripwww = child->stripwww; + } @@ -120,0 +132,10 @@ + +static const char *cmd_stripwww (cmd_parms *cmd, void *dummy, int flag) +{ + mva_sconf_t *conf; + conf = (mva_sconf_t *) ap_get_module_config(cmd->server->module_config, + &vhost_alias_module); + conf->stripwww = (flag ? STRIPWWW_ON : STRIPWWW_OFF); + return NULL; +} + @@ -229,0 +251,2 @@ + AP_INIT_FLAG("VirtualStripWWW", cmd_stripwww, NULL, OR_FILEINFO, + "flag to strip any www. prefix from host"), @@ -386,1 +410,1 @@ - const char *name, *map, *uri; --- + const char *map, *uri; @@ -389,0 +413,3 @@ + char *name_stripped, *name_current; + const char *strip_prefix = "www."; + char *name; @@ -412,1 +439,1 @@ - --- + @@ -414,1 +441,23 @@ - name = ap_get_server_name(r); --- + /* try to get the host from r->hostname rather than server, or + ap_get so that you get what was passed via mod_proxy_http */ + if (r->hostname != NULL){ + name_stripped = (char*)r->hostname; + name_current = (char*)ap_get_server_name(r); + } + else { + name_stripped = (char*)ap_get_server_name(r); + name_current = (char*)r->server->server_hostname; + } + + /* if the host does not match the servername & stripwww is set & + the www. prefix is present, then strip the www */ + if ( + (strcmp(name_stripped, name_current) != 0 && + memcmp(name_stripped, strip_prefix,4) == 0) || + (conf->stripwww == STRIPWWW_ON && + memcmp(name_stripped, strip_prefix,4) == 0) + ){ + name_stripped += 4; + } + + name = name_stripped;