views:

90

answers:

1

So I'm playing with a script that makes it super easy to mirror images off of the web. The script works great (based off of the old imgred.com source, if you've seen that) problem is, it looks a little clunky when using it.

Currently, in order to use the script, you go to a url like:

http://mydomain.com/mirror/imgred.php?Image=http://otherdomain.com/image.jpg

What I'd like to do is to be able to go to:

http://mydomain.com/mirror/http://otherdomain.com/image.jpg

and have it redirect to the former URL, preferably transparent to the user.

I'm reasonably certain that this can be done via .htaccess with a MOD_REWRITE of some kind, but I'm getting frustrated trying to get that to work.

+1  A: 

After messing with this myself, I found out that apache collapses any double slash in the URL before the query part into a single slash, and passes the result to mod_rewrite. Maybe that was giving you problems?

This might work for you (.htaccess in the mirror directory):

RewriteEngine On
RewriteBase /mirror
RewriteRule ^http(s?):/(.*) imgred.php?Image=http$1://$2 [L]

Don't know if your script accepts https addresses as well, so I included that just to be sure

Steef
Ahhh the double slash -> slash. funny, never ran into that before. thanks.
biggusjimmus