1

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

1 Answers1

3

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.

radius
  • 9,633
  • 25
  • 45