Scott
Scott

Reputation: 5379

.htaccess Regex Watermarking

I have an auto-watermarking script on my website, and the .htaccess file uses this line to redirect all images to the watermark.php file, which watermarks them. That I all have working, except the .htaccess line also redirects things like .js. So now my jQuery doesn't work anymore. The line is this:

RewriteRule ^([^thumb].*\.[jJ].*)$ watermark.php?src=$1

I didn't write it, I copied it from somewhere. I think it has to do with the jJ (for .js), but how can I change that to still work with images, but not JS files?

Upvotes: 2

Views: 575

Answers (1)

Paul
Paul

Reputation: 141887

The above regex matches any file whose extension begins with j or J, and whose filename doesn't consist entirely of t's h's u's m's and b's. Not exactly what they were going for I don't think.

RewriteRule ^(.*\.(?:jpe?g|bmp|gif|png|tiff?))$ watermark.php?src=$1

will rewrite anything with the extension:

  • jpeg
  • jpg
  • bmp
  • gif
  • png
  • tiff
  • tif

Upvotes: 5

Related Questions