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.
+4
A:
In .htaccess (in Apache at least):
RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*)$ http://www.yahoo.com/blah/$1 [R=302,L]
cletus
2009-01-30 06:42:33
Just as an additional hint: You need mod_rewrite installed on your server to use this.
BlaM
2009-01-30 14:24:23
+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
2009-01-30 07:52:31
+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
2009-01-30 14:21:19