You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Michael Altenhofen <Mi...@sap.com> on 1999/08/17 16:57:29 UTC

mod_rewrite/4869: Can't rewrite a URL if hostname part is followed by a port

>Number:         4869
>Category:       mod_rewrite
>Synopsis:       Can't rewrite a URL if hostname part is followed by a port
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Tue Aug 17 08:00:03 PDT 1999
>Last-Modified:
>Originator:     Michael.Altenhofen@sap.com
>Organization:
apache
>Release:        1.3.6
>Environment:
Debugger session under Windows/NT 4.0 Server, SP4 with VC 6.0.
Binary compiled from latest source kit. 
>Description:
I'll try to build up a rewrite rule logic that allows me to rewrite proxy requests on a per-dir basis. For that, I've included the following rule in httpd.conf:

RewriteRule ^proxy:([^:]*:)//([^/]*[/].*$) /proxyrequests/${ident-to-dir:%{REMOTE_ADDR}|default}/$2 [l,env=PTYPE:$1//]

An example rule in /proxyrequests/default/.htaccess could be this one:

RewriteRule (.*) %{ENV:PTYPE}$1 [p]

Now, if the requested URL contains a port number, like e.g. http://www.foobar.com:8080/, I'll get an Forbidden reply.

After hook_uri2file mod_rewrite reports an
"go-ahead with /apache/htdocs/proxyrequests/default/www.foobar.com:8080/ [OK]"

The subsequent "dirwalk" will fail, though, because "ap_os_is_filename_valid"
considers this file name invalid.

 
>How-To-Repeat:
See description above:

Add the RewriteRule to httpd.conf. You can omit the RewriteMap directive. I assume that doesn't change the behaviour. Set up the appropriate .htaccess file. Type in a URL that contains a port number.
>Fix:
I must confess that I still haven't completely figured out how mod_rewrite works. The PTYPE hack in the rule above is my poor man's solution to the fact that I can't keep the schema part in the URL, otherwise all rewrites will fail.

The short-hand work around is to also strip the host part from the URL and have mod_rewrite work on the rest. But then, I can't have such clever things like host based rewriting.

So I'm waiting for a more throughout solution, either by modifications to the software or by explaining me a more clever way to do the things I want to do.
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, you need]
[to include <ap...@Apache.Org> in the Cc line and make sure the]
[subject line starts with the report component and number, with ]
[or without any 'Re:' prefixes (such as "general/1098:" or      ]
["Re: general/1098:").  If the subject doesn't match this       ]
[pattern, your message will be misfiled and ignored.  The       ]
["apbugs" address is not added to the Cc line of messages from  ]
[the database automatically because of the potential for mail   ]
[loops.  If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request from a  ]
[developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]