Forum Moderators: phranque
I know how to set up mod_rewrite to rewrite to a different page than the one accessed eg. RewriteRule mypage\.htm otherpage.htm
I don't know if this is possible, but instead of rewriting to a specific page can you rewrite to more than one page, either randomly selecting or possibley selecting an equal amount of times each page from a predefined list of pages?
Any help/pointers would be great.
Cheers
Chris
According to Apache, the format for a RewriteRule is:
RewriteRule Pattern Substitution As you know, RewriteCond directives permit us to "massage" RewriteRules, making them conditional. I think you could create a condition (based on time of day perhaps) that would send visitors to different pages and it would appear to be a page selected at random.
The following rules will rewrite to file1.html if the current time is 0 to 29 seconds into the current minute, and to file2.html otherwise. If the first pattern matches, then we rewrite to file1 and stop rewriterule processing because of the [L] flag. Otherwise, the code falls through to the second rule, and we rewrite to file2.html and stop rewriterule processing.
RewriteCond %{TIME_SEC} ^[0-2][0-9]$
RewriteRule ^file\.html$ /file1.html [L]
RewriteRule ^file\.html$ /file2.html [L]
Ref: Apache mod_rewrite RewriteCond [httpd.apache.org]
HTH,
Jim