Figured it out - here's the solution I used:
1. Just above the JkMount line in httpd.conf, add the following lines to
turn on logging and setup a map of applications. Don't forget to replace X
with the current version number (i.e. 2.2.4).
RewriteLogLevel 3
RewriteLog c:/Tools/apache-X/logs/rewrite.log
RewriteMap apps rnd:c:/Tools/apache-X/conf/applications.txt
2. Create a conf/applications.txt file and add the following line to it:
sites app|app1|app2
3. Add a RewriteRule in <Directory "/opt/local/apache2/htdocs"> to use the
map:
# http://domain --> http://domain/app|app1|app2 (random application in
Tomcat)
RewriteRule ^(.*) /${apps:sites}/$1 [L]
4. Restart Apache, delete all cookies and open http://localhost. Refresh
your browser a number of times and watch yourself get routed to the
different applications randomly.
Thanks for all the help on this thread.
Matt
mraible wrote:
>
> It seems there's two ways to do this and I can't get either one to work.
>
> #1: Using a perl script:
>
> RewriteMap router prg:/opt/local/apache2/conf/router.pl
> RewriteRule ^(.*)$ ${router} [R,L]
>
> router.pl:
>
> #!/usr/bin/perl
> my $range = 3;
> my $random_number = int(rand($range));
>
> print "/?v=" . $random_number;
>
> Going to "http://localhost" in my browser results in:
>
> http://localhost/$%7brouter%7d
>
> #2 Using rnd
>
> RewriteMap servers rnd:/opt/local/apache2/conf/servers.map
> RewriteRule ^(.*)$ ${servers} [R,L]
>
> servers.map:
> /?v=0|/?v=1|/?v=2
>
> Going to "http://localhost" in my browser results in:
>
> http://localhost/$%7bservers%7d
>
> All my mod_rewrite settings follow the 2nd </Directory> in my httpd.conf.
> This is the one that starts with:
>
> <Directory "/opt/local/apache2/htdocs">
>
> I'm using Apache 2.2.4 on OS X.
>
> I have the following just before the RewriteMap lines:
>
> RewriteEngine On
> RewriteLog "/opt/local/apache2/logs/rewrite.log"
>
> For some reason rewrite.log is created, but nothing is in it.
>
> Thanks in advance for any help,
>
> Matt
>
>
> Joshua Slive-2 wrote:
>>
>> On 4/18/07, Serge Dubrouski <[EMAIL PROTECTED]> wrote:
>>> A simple JavaScript serving as a main page and redirecting users to a
>>> random URI from your site would do. I don't think that it would be
>>> possible to do on Apache configuration level
>>>
>>> On 4/18/07, mraible <[EMAIL PROTECTED]> wrote:
>>> >
>>> > Is it possible for Apache to randomly select different URLs to serve
>>> up? For
>>> > example:
>>> >
>>> > User1 -> http://my.domain.com/1
>>> > User2 -> http://my.domain.com/2
>>> > User3 -> http://my.domain.com/3
>>
>> Actually, mod_rewrite can do it using a rnd: RewriteMap.
>>
>> Joshua.
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> " from the digest: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Is-it-possible-for-Apache-to-randomly-select-different-URLs-to-serve-up--tf3603013.html#a10110297
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]