I'm only guessing this is in mod_dir...it could be in mod_rewrite or something entirely different for all I know. Here's how to reproduce: 1. run a webserver on port 8080: Listen 8080 2. create a cgi-directory with the following properties Options +ExecCGI AddHandler cgi-script .cgi DirectoryIndex index.html ... index.cgi 3. create a file called index.cgi in that directory: - - - - - - - - %< CUT HERE >% - - - - - - - - #!/bin/sh echo 'Content-type: text/html' echo echo '<pre>' echo "\$SCRIPT_URI = $SCRIPT_URI" echo '</pre>' exit 0 - - - - - - - - %< CUT HERE >% - - - - - - - - 4. Navigate to that file on your server. For example: lynx -source http://somehost.somedomain:8080/cgi-bin/index.cgi You should see the following output: <pre> $SCRIPT_URI = http://somehost.somedomain:8080/cgi-bin/index.cgi </pre> 5. Now navigate to just the CGI directory and let DirectoryIndex resolve to index.cgi for you. For example: lynx -source http://somehost.somedomain:8080/cgi-bin/ You should now see the following output: <pre> $SCRIPT_URI = http://somehost.somedomain/cgi-bin/ </pre> 6. Notice how the port is missing in the second output. Another way to see this is when running PHP in Apache. The $_SERVER['SCRIPT_URI'] entry will be missing the port number for any script arrived at through DirectoryIndex resolution. I have not tried experimenting with any of the Rewrite* directives. I have not tried this in Apache 1.x.
I should have noted that this happens on any non standard port (not just 8080).
This may also be related to bug #17148.
Oops...I meant bug #17149. :-/
This is still a major pain in the butt, but I haven't seen any activity or comment on this one. I'm changing the component to be what I believe is more accurate.
Perhaps this isn't mod_rewrite's fault after all. From mod_rewrite (2.0.50): 1125 /* 1126 * create the SCRIPT_URI variable for the env 1127 */ 1128 1129 /* add the canonical URI of this URL */ 1130 thisserver = ap_get_server_name(r); 1131 port = ap_get_server_port(r); 1132 if (ap_is_default_port(port, r)) { 1133 thisport = ""; 1134 } 1135 else { 1136 apr_snprintf(buf, sizeof(buf), ":%u", port); 1137 thisport = buf; 1138 } This looks pretty simple. As far as I can tell, ap_get_server_port is defined in server/core.c, and ap_is_default_port is a macro defined in include/httpd.h which expands to: "(port == ap_run_default_port(r))". Unfortunately, I'm not very adept at internal Apache development, and ap_run_default_port is defined via some hook function macro magic that I don't fully understand. Can anyone verify what the output of "ap_get_server_port(r)" and "ap_is_default_port(port, r)" are in this context (i.e., when browsing to an implied file via DirectoryIndex a la the above)?
doesn't really look like a mod_rewrite problem to me
Doesn't look like a problem at all. It's perfectly fine because port 80 is the default port for the http scheme.
Davi, you closed the bug without actually reading any of the comments or understanding it. This has nothing to do with port 80. This has to do with using a non-standard port (see comment #1) and DirectoryIndex. Please run through the examples yourself before just blindly closing bugs without actually taking the time to understand them.
Yes, I may have initially misunderstood. This has to do with internal redirects, and since internal redirects "have no ports", the default port is 80 for the sub request. I don't think it's worth propagating this down the sub request, since it's another request.
I can't reproduce the problem with 2.0.60-dev. If more information appears later, please re-open the bug. [davi@montefiori 2.0.x]$ lynx -source http://localhost:8080/cgi-bin/ <pre> $SCRIPT_URI = http://localhost:8080/cgi-bin/ </pre>