You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2020/02/05 16:12:21 UTC

[Bug 64117] New: Apache is not logging original URL %
https://bz.apache.org/bugzilla/show_bug.cgi?id=64117

            Bug ID: 64117
           Summary: Apache is not logging original URL %<U or original
                    query %<q when using RewriteEngine
           Product: Apache httpd-2
           Version: 2.4.41
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_log_config
          Assignee: bugs@httpd.apache.org
          Reporter: rebus@seznam.cz
  Target Milestone: ---

Hello,
when using RewriteEngine it seems that the original URL path of the request
(%<U) is not logged. 

Tested on apache 2.4.6 present in RHEL7 and 2.4.41 in Fedora 31.

No matter if I use %U or %<U or %>U in the LogFormat, the output written to the
log file is always containing the url after rewriting. Same applies for the
query string (%q %<q %>q).

According the documentation
http://httpd.apache.org/docs/current/mod/mod_log_config.html it should be
possible to use "<" and ">" modifiers to distinguish between original and final
value, but it doesn't work for %<U and %<q when using the RewriteEngine. The
only formatting string which holds the original URL seems to be %r.

For example having application, which redirects all URL and query parameters to
handler index.php :
    RewriteEngine On    # Turn on the rewriting engine
    #===== Pass requests for nonexisting files to index.php
    RewriteCond "/var/www/html/%{REQUEST_FILENAME}" !-f
    RewriteRule "(.*)" "/index.php?path=$1" [PT,QSA]

So user requesting http://test.com/hello/world?param1=value1 will be actually
processed by http://test.com/index.ph?path=/hello/world&param1=value1 

I would like to log Custom log with the original URL, but it doesn't work ...
for example:
LogFormat "%h %l %u %t \"%m http://%{Host}i%<U%<q %H\" %>s %b" common_full_url 


Best regards
Michal Ambroz

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 64117] Apache is not logging original URL % Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64117

--- Comment #3 from Eric Covener <co...@gmail.com> ---
(In reply to Michal Ambroz from comment #2)
> Hello Eric.
> I do not think I follow you with setting the  envvar?
> Some example please?

In your rewriterule something like [PT,E=ORIG_URL:$0]

> 
> My understanding is that %<U should preserve the original url as received
> from the client.

```
The modifiers "<" and ">" can be used for requests that have been internally
redirected to choose whether the original or final (respectively) request
should be consulted.
```

It is specifically for internal redirects (which are a type of "sub-request").
Anything that just modifies the main/original request will not generate an
internal redirect, so there is no separate "original"/"final" request.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 64117] Apache is not logging original URL % Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64117

--- Comment #2 from Michal Ambroz <re...@seznam.cz> ---
Hello Eric.
I do not think I follow you with setting the  envvar?
Some example please?

My understanding is that %<U should preserve the original url as received from
the client.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 64117] Apache is not logging original URL % Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64117

--- Comment #1 from Eric Covener <co...@gmail.com> ---
In non-directory/htaccess context, rewrites don't trigger internal redirects,
which is what those special characters unwind.  Without PT, these rewrites just
change the mapped filename. With PT, they change the URL-path %U in-place.

I think if you want to preserve it, you need to set it aside into an envvar.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org