Forum Moderators: phranque

Message Too Old, No Replies

https rewrite log

What does this log file contain?

         

theblade24

10:30 pm on Jan 28, 2007 (gmt 0)

10+ Year Member



What does the log file https_rewrite_log contain?

It seems like everything my server does, all the http requests, are getting written to it.

jdMorgan

11:40 pm on Jan 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Normally, this file would contain information logged by mod_rewrite.

If you are getting lots of stuff logged in this file, check the setting of RewriteLogLevel [httpd.apache.org] in your server configuration files. It should normally be set to zero or set to a very low number to minimize mod_rewrite activity logging, and only set higher if you are actively debugging mod_rewrite problems on the server.

Sometimes, people will enable rewrite logging to test, and then forget to turn it off.

I assume that no-one has pointed some other logging function the same file, which could also happen.

Jim

theblade24

1:53 pm on Jan 30, 2007 (gmt 0)

10+ Year Member



Thank you so much! That was it. There was NO directive regarding log location or log level for rewrite in the httpd.conf file. This is a default new install of CentOS.

It was writing everything, and writing to the default location of /var/log/httpd/https_rewrite_log file.

It was writing a gig a week so I set it to zero.

One last question...

recommended setting of UseCanconicalName

off? or on?

jdMorgan

3:41 pm on Jan 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you do not control the setting of ServerName --that is, if you do not or will not have access to httpd.conf-- then I recommend setting UseCanonicalName to "Off". If you do have server config access, then this setting is up to you. If you do turn it on, make sure that the ServerName is the exact domain name that you prefer to use.

Jim

pmkpmk

4:17 pm on Jan 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Funny, I am experiencing quite a lot of coincidences this week, and this thread is one of them.

I am using some handfuls of "vanity domains" and generic domains to guide type-in traffic to my sites. In order to avoid duplicate content issues, there is some extensive rewriting at work. I always wanted to know exactly how much type-in traffic to those domains I actually get. The regular logfiles don't show this - they only log AFTER the rewriting has been done.

Would this directive help me get the requests PRIOR to rewriting? How would I configure it? I would not want to configure a virtual server for each to-be-rewritten-domain - that would somehow counteract the concept...

Could someone post a sample of this logfile?

Thanks!

theblade24

4:29 pm on Jan 30, 2007 (gmt 0)

10+ Year Member



Turned it off.......

Thanks for your help!

jdMorgan

5:07 pm on Jan 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The rewrite log is not anything like your server access log. It is for debugging mod_rewrite, and not likely of much use for gathering 'stats' information.

> I would not want to configure a virtual server for each to-be-rewritten-domain - that would somehow counteract the concept...

I'm not sure what you mean by "counteract the concept" exactly, but consider setting up a virtual server for each domain, and the pointing them all to the same document_root. That way, you can log them separately, but serve the same content for all.

Jim

pmkpmk

9:05 am on Jan 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, let me explain. Right now my virtual server setup looks like this:

<VirtualHost *>
ServerName www.mysite.com
ServerAlias mysite.com
ServerAlias www.generic1.com
ServerAlias generic1.com
ServerAlias www.generic2.com
ServerAlias generic2.com
[... other virtual server setup code ...]
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.mysite\.com
RewriteRule (.*) http://www.mysite.com$1 [R=301,L]
</VirtualHost>

So in the front section I declare responsibility for all the secondary domains, and the last rewrite-block rewrites anything to the proper URL.

However, if someone launches the browser to www.generic1.com, all I get in my logfiles are accesses to www.mysite.com. What I am looking for is a way to get some kind of logging of how many people actually tried to access generic1.com - and where they possible came from. That would enable me to use the domain name as a kind of "tracking parameter" in print advertising etc.

jdMorgan

3:52 pm on Jan 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, if you don't want to split those into separate vHosts, then maybe you'll like this solution better:

SetEnvIf HOST "^(www\.)?mysite\.com(:[0-9]{1,5})?$" Dom_mysite
SetEnvIf HOST "^(www\.)?generic1\.com(:[0-9]{1,5})?$" Dom_generic1
SetEnvIf HOST "^(www\.)?generic2\.com(:[0-9]{1,5})?$" Dom_generic2
SetEnvIf HOST "^(www\.)?generic3\.com(:[0-9]{1,5})?$" Dom_generic3
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" ExC_NCSA
#
CustomLog logs/mysite.log ExC_NCSA env=Dom_mysite
CustomLog logs/generic1.log ExC_NCSA env=Dom_generic1
CustomLog logs/generic2.log ExC_NCSA env=Dom_generic2
CustomLog logs/generic3.log ExC_NCSA env=Dom_generic3

With this configuration, requests will be logged to the files <document_root>/logs/<hostname>.log

So, the initial requests to each "generic" host will be logged to separate files. After your mod_rewrite code redirects these initial requests to mysite.com, those redirected requests will be logged to the mysite.com log.

See Apache mod_log_config [httpd.apache.org]

Jim

pmkpmk

4:50 pm on Jan 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh my... looks like magic to me.

Will the initial request be logged TWICE (once in the generic log and once in the rewrite log), or only ONCE (to the generic log)?

I would hope for TWICE, but I assume once.

jdMorgan

5:42 pm on Jan 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The description I gave was specific: The initial HTTP request is logged to the requested host's log file. If that request is redirected, then the second (redirected) request will be logged to whatever host it is made to. Each request is logged to the log file of whichever host it is made to.

If it's not clear, an HTTP redirect response from your server terminates the current client request, and tells the client to re-request the desired resource from the server using the new URL provided in the redirect response. Therefore, if the first HTTP request is made to "generic1", it gets logged in the generic1 log file. If your mod_rewrite code then redirects that request to "mysite", then the resulting second HTTP request gets logged to the mysite log.

Jim