Recently I noticed that one of our client websites was creating many 404 “not found” errors in our NGINX server logs. The errors were for “@2x.jpg” static files. I believe that the active WordPress theme was coded to server @2x file URLs for retina and other HDPI screens, but the files are not automatically generated. Rather than dig into the theme’s template files and attempt some kind of patch, and since the website already looks great on high definition devices, I chose to look at adding a rule in the site’s NGINX .conf to stop these pesky 404s.

Normally a few Google searches would return a StackOverflow page with exactly the nginx rules required, but this time I could not dig up any pages where this problem had been addressed and fixed.

For Apache there was this post, where the .htaccess rules were perfectly coded. I even tried converting this ruleset to NGINX using an online converter, but the result was full of errors.

After some brief experimentation, I have a working NGINX ruleset that has solved my retina image 404 issue.

# rewrite retina image requests
location ~* ^(.*)\.(jpg|jpeg|png|gif)$ {
if ($request_filename ~ '@2x\.[a-z]+$') {
rewrite ^(.*)\@2x(.*)$ $1$2 last;
}
}


Andrew Miller

Online since the "brrr-bleep" era. Proud father and husband. Internet geek.

You might also be interested in


Hosting

Let’s Encrypt cert renewals broken after Debian 10 ‘Buster’ upgrade

One of the upgrades in Debian 10 is a Python upgrade to v3.7.2. This can cause certbot renewals to break. It's an easy fix! Read More

Business

Total Online Start-up Kit for Business

Every online business requires these five fundamental components: Branding, Website, Email, Domain Name, and Hosting. Some businesses already have one or more of those components already in place. Brand new businesses require all five. Traditionally, each component would be separately estimated, developed and billed. We have a new plan, with much lower entry cost: All-in-one, Total Online Start-up Kit for Business. Let’s dig in. Read More

Hosting

Managed Website Hosting

While there are many providers in the global and domestic managed hosting market, Brightwood Creative should still be your all-in-one solution for website Hosting. Read More

Let Us Help You.

At this point you should hopefully have a pretty good idea what we do. Sometimes people want to know more. Either way, the best way to get this ball rolling is to reach out. Seriously, just call us. We are very nice people.

phone

Give us a ring

General Sales & Enquiries
info@brightwood.ie
+353 (0) 851466889
Mon - Sun, 8:00-22:00

Help & Support

support@brightwood.ie
+353 85 1466889
Mon – Sun, 8:00-22:00

Feel Like Reaching Out?

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

Privacy Settings saved!
Privacy Settings

When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.

These cookies are necessary for the website to function and cannot be switched off in our systems.

In order to use this website we use the following technically required cookies
  • wordpress_test_cookie
  • wordpress_logged_in_
  • wordpress_sec

Decline all Services
Accept all Services