Web Development » Alias local paths to remote images

Alias local paths to remote images

Don’t you hate it when your local development environments just show you a bunch of broken images? This typically happens with sites hosting photo galleries, lots of product shots, etc. You don’t necessarily want to have all of your images on your local, but of course they need to be there on your live server, and rather than write out absolute paths this little trick will come in handy.

In your htaccess file just add the following:

RewriteEngine On
RewriteRule ^(product_images/.*) http://www.example.com/$1 [L]

So there you have it, hope it helps and have fun coding!

Comments