Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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

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. –  sam May 24 '11 at 20:18
    
When I go directly to the image, for example: myWebsite.ca/img/logo.jpg, 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 –  sam May 24 '11 at 20:36
    
Thanks that worked ! –  Bastien974 May 25 '11 at 12:25
show 1 more comment

Your Answer

 
discard

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.