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

1 Answer

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

Your Answer

 
discard

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