Status
Not open for further replies.

AlternativeWeb

Active Member
512
2010
154
0
Is it possable to use .htaccess to rotate image using the same URL?


For exmaple:
domain.com/random.jpg


Redirect to randomly:
domain.com/image1.jpg
domain.com/image2.jpg
domain.com/image2.jpg
 
9 comments
Indeed it would be easier if you use a php script for it.

Just make a folder called random.jpg and place the script alongside with the images there and it would get rotated. :)
 
its simple using php.
use rand() function to get a value.
check for random value against your desired number or range.
redirect if it meets the requirement.

edit:
you can use htaccess rewrite rule
like RewriteRule ^/img.jpg ./random.php
 
I actually wanted to make it for the default avatar images for my forum.
So it would need to be an actual URL instead of a php script.

Indeed it would be easier if you use a php script for it.

Just make a folder called random.jpg and place the script alongside with the images there and it would get rotated. :)

If you followed this method you could just copy the link to your url - http://yourdomain.com/random.jpg and your avatar would rotate just fine. You don't need to link it to your php file but make sure in the folder named "random.jpg" you place the php file named "index.php". This way your avatar would load just fine. :)
 
Status
Not open for further replies.
Back
Top