1

For an acute server crash problem, I'm trying to match any request for @2x retina style images, and rewrite it to the non-@2x equivalent.

First I want to check this is such a request:

# NOTES: Check the file name to see if it matches the @2x pattern:
RewriteCond %{REQUEST_FILENAME} ^(.*)(@2x\.\w+)$ [NC]

For example:

media/catalog/product/cache/1/thumbnail/100x/9df78eadfvrtdfgdfg6e5fb8d27136e95/i/n/insample-123_1@2x.jpg

Then I need to just take out @2x and return:

media/catalog/product/cache/1/thumbnail/100x/9df78eadfvrtdfgdfg6e5fb8d27136e95/i/n/insample-123_1.jpg

Could be png or jpeg or PNG or gif etc.

I'm no RegExp ninja. I know how to replace parts, but not remove. Can anyone please assist? My servers are dying because of 404's...

EDIT: Seems like it's:

RewriteCond %{REQUEST_FILENAME} ^(.*)(@2x\.\w+)$ [NC]
RewriteRule (.+)@2x\.(\w+)$ $1.$2 [R=302]

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.