Re: Is it possible for Apache to randomly select different URLs to serve up?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <sergeyfd@xxxxxxxxx> 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 <matt@xxxxxxxxxxxxxxxxx> 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: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-it-possible-for-Apache-to-randomly-select-different-URLs-to-serve-up--tf3603013.html#a10089394
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: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux