Click to See Complete Forum and Search --> : .htaccess, redirect to HTTP_HOST specific folder.


eikhorsholm
February 25th, 2011, 06:02 AM
I'm trying to have the server lookup files/images in a different folder, than typed in the address bar.

For example, if somebody types
http://my-domain.com/images/test.jpg
the server should look for the image in:
/images/my-domain.com/test.jpg and not /images/test.jpg as it normally would.

I've managed to get the domain-name into the RewriteRule, but it still isn't working:
RewriteRule ^images/(.*) images/%{HTTP_HOST}/$1 [L]

This WORKS:
RewriteRule ^images/(.*) images/%{HTTP_HOST}/test.jpg [L]
But here the image, test.jpg, is hard-coded which it of course shouldn't be.

Can anybody help? And does it make any sense?

PeejAvery
February 25th, 2011, 01:44 PM
Oh so close. Try the following instead...

RewriteRule ^images/(.*)$ images/%{HTTP_HOST}/$1 [L]

eikhorsholm
February 25th, 2011, 03:13 PM
Well, it does something else now.

But in my error log I now get (I didn't get that before):
Request exceeded the limit of 10 internal redirects due to probable configuration error

PeejAvery
February 27th, 2011, 02:04 PM
Try it without the parenthetical regular expression.

eikhorsholm
February 28th, 2011, 02:41 AM
This made the trick:
RewriteCond %{REQUEST_URI} !^/uploads/.*?/.*$