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 rule that will get the extension of every file from the url. I need to match all jpg, gif, png and bmp files. This is for a watermark application. Currently, it only matches jpg and Jpg. Can someone help me match all four extensions?

Here is what I currently have so far.

RewriteRule ^(.*\.[jJgG].*)$ /test.php?i=$1
share|improve this question

Take a look to this
You will learn that you can use [NC] to do a case insensitive match.
Your .* at the end seems strange if you only want to match url ending with jpg, etc.. So what you want is probably this:

RewriteRule ^/(.*\.(jpg|gif|png|bmp))$ /test.php?i=$1 [NC]

Note that in the doc there is almost the same RewriteRule.
You may want to use [NC,P] to make the rewrite rule to be processed internaly rather than sending a redirect message to the broswer.

share|improve this answer

Your Answer


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