views:

243

answers:

4

How do I set up an .htaccess file to redirect requests to another folder on another domain? I don't want the links to break, I just want them to go elsewhere. Say mysite.com/image.jpg would redirect to site2.com/images/image.jpg.

A: 

This should help:

Redirect 301 / http://www.example.com/

HappyCodeMonkey
+4  A: 

In .htaccess (in Apache at least):

RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*)$ http://www.yahoo.com/blah/$1 [R=302,L]
cletus
Just as an additional hint: You need mod_rewrite installed on your server to use this.
BlaM
+1  A: 

Now, what a big surprise, the official documentation has lots of useful examples, including what you are looking for. Yeah, it really sucks that Google is down so often.

Bombe
'twas for me, earlier ;-)
Chris
+1  A: 

You could use mod_rewrite to redirect the request. If you want to redirect everything:

RewriteEngine on
RewriteRule ^ http://other.example.com/images%{REQUEST_URI} [L]

And if you just want to redirect requests with a path that end in .jpg:

RewriteEngine on
RewriteRule \.jpg$ http://other.example.com/images%{REQUEST_URI} [L]
Gumbo