Forum Moderators: phranque

Message Too Old, No Replies

Show Full URL in apache Logs

How To

         

Anyango

5:19 am on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As you know standard setup of apache access logs will show / for root page and page-name.html for any page thats requested.

can it be made to show Complete URL of the page which was requested, in the log? for example

00.00.00.000 - - [16/May/2005:22:48:31 -0500] "GET / HTTP/1.1" 403 3985 "-" "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"

thats obviously a request for root page of the domain, is there a setting that i can make in apache so next time when that root page is requested, apache shows this in log

00.00.00.000 - - [16/May/2005:22:48:31 -0500] "GET mydomain.com/ HTTP/1.1" 403 3985 "-" "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"

similarly for other pages show

mydomain.com/any-page-that-was-requested.

Any assistance is appreciated.

Thanks
Kami

jdMorgan

4:27 pm on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, not directly, because Apache is showing you the HTTP Request header sent by the client, which does not include the domain.

The domain/host name, if the client sends it, is available in the separate "Host" header, so you should be able to log it using \"%{Host}i\" in mod_log_config [httpd.apache.org], but not in the exact "example.com/page.html" form you want.

Remember that hostnames are 'new' for HTTP/1.1; They were not supported in HTTP/1.0, and every domain used to have to have a unique IP address. That is why the hostname is sent as a separate header -- It is a recent 'add-on' to the HTTP protocol [w3.org]. Any robust server-side coding for sites with unique IP addresses should make provisions for old HTTP/1.0 clients, which will not send the "Host" request header. However, note that this is not a concern on name-based virtual servers, since such servers will not be reachable if the Host header is not sent.

Just to be clear, here is an example of a request that a simple client might send to your server:

GET /test.html HTTP/1.1
User-agent: Mozilla/4.0 (compatible; jd-browser)
Host: www.example.org

Jim