Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to change a jpg path to point to a different picture in a website. This has to be done through the apache conf because the website is always updated with git.

The point is to help the developers to easily see they are working on which dev environment, so if I can rewrite the path a the main logo to something else in their home that would be perfect.

I tried to add this in the VirtualHost configuration: RewriteRule ^/img/logo.jpg /home/someUser/logo2.jpg

share|improve this question
up vote 4 down vote accepted
<Directory /path/to/documentroot/>
    RewriteEngine on
    RewriteBase /
    RewriteRule ^img/logo.jpg$ path/to/logo2.jpg

path/to/logo2.jpg must be under the document root (So in your example /home/someUser/ should be the document root of the site). You can't create rewrite rules to files above the document root (I.E. if your root is /var/www/html/ you couldn't create a rewrite rule to /var/www/hello.html)

share|improve this answer
I get this error : RewriteBase: only valid in per-directory config files – Bastien974 May 24 '11 at 20:15
Oh I assumed you would be putting this in a .htaccess file. I'll update the code to show you the directory based config. – Smudge May 24 '11 at 20:18
When I go directly to the image, for example:, i'm not redirected to /img/logo2.jpg – Bastien974 May 24 '11 at 20:34
You shouldn't be redirected, rewrites are server-side so on the frontend the URL won't change. If you want it to change add [R=301] to the end of the RewriteRule line – Smudge May 24 '11 at 20:36
Thanks that worked ! – Bastien974 May 25 '11 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.