Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache mod_rewrite redirect file type to another domain

How can I use mod_rewrite to send requests for a particular file type to another domain name (server)?

Example:

If you request http://example.com/potato.png then it'll redirect to http://anotherdomain.com/potato.png.

like image 584
James T Avatar asked Aug 22 '11 23:08

James T


1 Answers

Here's a quick solution to redirect images with jpg, gif or png extension to anotherdomain.com

RewriteEngine on
RewriteRule \.(gif|jpg|png)$ http://anotherdomain.com/%{REQUEST_URI} [NC,R=301,L]   
like image 72
Book Of Zeus Avatar answered Nov 15 '22 20:11

Book Of Zeus