help on HTACCESS

iosoft

PC enthusiast since MS DOS 5
Skilled
My knowledge in HTACCESS is very limited.

Currently I wrote a script that will redirect albums.mysite.com/images/ to www.imageserver.com/images/

Here is the CODE -

Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^albums.mysite.com$

RewriteRule ^images/?(.*)$ http://www.imageserver.com/images/$1 [R=302,L]

But I want that, this redirection will only work if a image-file is included with albums.mysite.com/images/

that is -

it will redirect to www.imageserver.com/images/abc.jpg (or GIF or PNG etc)

if

http://albums.mysite.com/images/abc.jpg

BUT,

it will redirect to -

http://albums.mysite.com/index.php

if called by just -

http://albums.mysite.com/images/

How to do that ?
 
Worked on htaccess files long ago

did you try using the online htaccess generators.

Check this out, might help you.

.htaccess File and mod_rewrite examples

RewriteRule ^images\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ http://www.imageserver.com/images/$1 [R=302,L]

Im pretty sure above code wont work, you need to try different combinations of (bmp|tif|gif|jpg|jpeg|jpe|png) in your rewrite rule.
 
Back
Top