Problem Description
All of the following must be true for the solution below to work:
- You're using a web application like PrestaShop or WordPress Multisite, and/or you have a .htaccess file with image path rewrites
- All or some images are not showing / loading on your website (for PrestaShop it's only product images)
- When you check the browser console or server logs, it shows 404 errors when loading images
- The browser console and server log will provide the path to the image. When you check the path to the image file on the server using Plesk File Manager or FTP, the image really doesn't exist at that location
This means that your site is using apache rewrites to serve the image files.
If your website's rewrites, found in the .htaccess file, send image file requests to a php file like index.php (common in WordPress multisite and other apps), this means every single image request will load a PHP process to handle it, which is poor for website performance.
Because of this performance drop, our servers are configured to behave in an optimized manner by immediately providing a 404 when the image file does not exist at the location on disk, thus blocking PHP processing for static resources.
Alternative Problem with the same solution:
- You're using software that generates a file that is expected to be static (like .txt, or .png) dynamically rather than creating the actual file on disk. (example: ads.txt)
Problem Resolution
There are two ways to resolve this. They are in order of best solution to worst solution for performance:
- The best solution is to check your web application's documentation and support articles to determine if there is a configuration for the app that will generate your site's HTML using the correct URLs to the image path on disk, rather than using a fake/friendly URL that then needs PHP processing to load them.
- If there's no way to force the app to use the actual path on disk for these files, you can bypass our optimizations by adding a blank file called
.dynamic404
(it must be preceeded with a dot) in your website's web root folder (for primary domains, this is usually httpdocs).
Example for Prestashop: in the admin, go to Preferences (or Shop Settings) > SEO & URLs > Disable Friendly URLs
IMPORTANT NOTE: If you use option (2) and you get an increase in traffic your site will very likely exhaust its PHP resources fast. If this occurs, your only good solution is to migrate to a VPS. On the flip side, if you find a way to directly link to the file on disk, your site will very likely be able to handle far more traffic without requiring an upgrade of service.