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¶m1=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
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.
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.
(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.