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 have a working redirection that looks like this

RewriteRule ^(.*)weihnachtsshop/(.*)$ /hochzeitsshop [R=301,L]

everything like get's redirceted to

My problem now is, that i need this redirection to exclude all images, like - these links should not get rewritten.

What's the best way to approach this?


share|improve this question
I'd be interested in the solution to this too. – Jonathan Ross Mar 29 '11 at 13:36
RewriteCond %{REQUEST_FILENAME} !-f redirects only file that does not exist. It could be enough in your case no ? – Serty Oan Mar 29 '11 at 13:50
up vote 4 down vote accepted

One way:

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|gif|png)$
RewriteRule ^(.*)weihnachtsshop/(.*)$ /hochzeitsshop [L,R=301]
share|improve this answer
and bmp or tiff, webp ? :p (just kidding) – Serty Oan Mar 29 '11 at 14:12

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.