Forum Moderators: phranque

Message Too Old, No Replies

logging for multiple subdomains on same IP

Requesting help on configuring Apache for multi-subdomain logging

         

bailywolf

7:08 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



We have a web server running Apache, and have recently acquired a new subdomain which will eventual phase out the old sumdomain.

Currently both these URL's would resolve to the same resource:

www.oldsub.dom.edu

www.newsub.dom.edu

The uni's DNS has entries for the machine's IP so either address resolves without issue.

We're going to phase out the old subdomain and replace it, but we'd like to track user access to our sites through one or the other. We use AWStats, but with a single log file, it can't distinguish the different subdomains (with seperate AWStats config files, we end up with the same stats).

So, is there a way to have our Apache host resolve both those URL's to the same resource, BUT log that traffic into different log files?

Thanks,

-B

jdMorgan

10:35 pm on Sep 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache mod_setenvif and mod_log_config

You can set an environment variable based on the hostname, and control logging with it in mod_log_config.

Jim

bailywolf

12:12 pm on Sep 14, 2007 (gmt 0)

10+ Year Member




Cool- I was starting to look into those options, and wondering if they would indeed do what i thought they would.

Nice.

Thanks for confirming I was on the right track.

-B

bailywolf

12:58 pm on Sep 14, 2007 (gmt 0)

10+ Year Member



Would a mod_setenvif directive configured thusly give me what I need:

SetEnvIfNoCase Host newsubdom\.uni\.edu site=newsubdom

This would set site equal to "newsubdom" if the host portion of the header contained any case-insensitive combo of newsubdom.uni.edu, yar?

-B

bailywolf

3:36 pm on Sep 19, 2007 (gmt 0)

10+ Year Member




I'm having no luck with this.. here is the config I'm trying to use for this:

SetEnvIf Host newsub\.uni\.edu site=newsub

CustomLog logs/newsub_log combined env=site-newsub

I'm trying to set "site" equal to "newsub" if the requested URL contains "newsub.uni.edu". Then, I'm trying to log into the "newsub_log" file in the combined format if "site" equals "newsub".

But I'm nothing is being written to the new log file. Rather, all the traffic from both oldsub and newsub based URL's is getting written to the main log file.

So essentially, the above does nothing.

Anyone throw me a bone?

-B