Redirect from one image to another?

Trying to redirect from one image to another but can’t quite seem to be able to do it ? In the .HTaccess am trying :

RewriteRule old_image.jpg /new_image.gif [R=301,L]

Both images are in the root.

Any help much appreciated.

Dez.

Hi David, can you just confirm that Redirect 301 /old_image.jpg /new_image.gif would be ok please ? Getting a 500 internal server error ?

Thanks David, that’s very much appreciated. I was a little confused on the alias part, is the code below the best way to do this please ?

Redirect 301 /old_image.jpg /new_image.gif

:tup:

Regards,

DK

Hi Dez,

Yes, but check this Redirect anchor at apache.org. The URL can be either external (as in their examples) or internal but it MUST be an ABSOLUTE URL. If in doubt, use the external version.

If you’re getting a 500, I’d suggest posting the rest of your .htaccess for review as that’s an indication of a syntax error.

Regards,

DK

Dez,

First, .HTaccess is .htaccess and your version WILL fail on a 'nix box where capitalization is critical (without mod_speling, that is).

Second, your mod_rewrite is okay although I should nag about not escaping the dot character in the regex and not using the leading / in the redirection.

Finally, mod_alias’ Redirect is the correct tool to use as it does not require loading of the regex engine to process a simple redirect like you’re attempting:

Redirect 301 /old_image.jpg /new_image.gif
Edit:

Using the proper tool will optimize things on the server so the first thing to learn about using mod_rewrite is when NOT to use it (in favor of the more appropriate tool). In this case, a single redirect is better suited to mod_alias whereas multiple redirects which are suitable to using the POWER of regular expressions are more likely to fall into the mod_rewrite category.

Regards,

DK