How to fix WooCommerce file not found error

You might have updated your WooCommerce plugin to the latest version and you encountered the file not found go to shop error. This error means that the file cannot be reached because of lack of Apache mod_xsendfile module. Below are two solutions to the problem. 

Solution 1 (enable Redirect Only) 

This is a temporary solution to enable clients download their products as you work on a permanent solution.  

fix File not found woocommerce error after update
fix File not found WooCommerce error after update/Photo
  • Go to WooCommerce Menu
  • Click settings 
  • Then click Products 
  • Under Products, go to Downloadable products 
  • Then under File download method select Redirect Only 
  • Then click the save changes button 
  • Test whether the products can now be downloaded 

WARNING: Solution 1 approach is not recommended by WooCommerce because after making a purchase, the buyer can see the URL of the file being downloaded for example (https://blogiestools.com/file.pdf), and share it anywhere (including social media). The file URL can also be accessed by any user without necessarily having to log in.

NOTE: If you must use solution 1, it is advisable to stop people from linking to your website files by preventing hotlinking. Add the code below your .htaccess file to prevent hotlinking.  

## BEGIN PREVENT HOTLINKING ##
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)example.com/.*$ [NC]
RewriteRule \.(zip|rar|mp3|docx|doc|pdf)$ - [F]

## END PREVENT HOTLINKING ##

You can remove or add any file extension that you want to disable hotlinking in the last line. In the example above, we have prevented linking to zip, rar, mp3, docx, doc, and pdf file extensions.  

Solution 2 (enable mod_xsendfile Apache module) 

This solution requires someone with root access. You will be required to install mod_xsendfile Apache module.  

  • Install the package by running the following command via SSH. 
yum install ea4-experimental
yum install ea-apache24-mod_xsendfile
  • end or exit command
  • Restart apache server
  • Go to easyApache modules and enable mod-xsendfile and click next upto the last next button and then click provision. Once provision process is complete
enable install mod xsendfile
enable install mod xsendfile/Photo
  • Go to WooCommerce>settings>products>downloadable products and select X-Accel-Redirect/X-Sendfile
  • Add the code below to htaccess if X-Accel-Redirect/X-Sendfile does not work after running the command above 
<IfModule mod_xsendfile.c>
  <Files *.php>
    XSendFile On
    SetEnv MOD_X_SENDFILE_ENABLED 1
  </Files>
</IfModule>

If you are on shared hosting and you are not able to install mod_xsendfile then contact your host.  

Solution 3 (remove spaces from download url)

If you have few products, you can manually re-upload the file to be downloaded without any spaces and then regenerate download permission so that users who had purchased it can be able to download in future.

After uploading the download file without any spaces in the url, go to  WooCommerce settings and set the file download method to whichever you want. It should work.