szepeviktor / w3-total-cache-fixed

A community driven build of W3 Total Cache. The aim is to continuously incorporate fixes, improvements, and enhancements over the official WordPress release of W3 Total Cache.
https://github.com/szepeviktor/w3-total-cache-fixed/releases
MIT License
237 stars 47 forks source link

CDN Cloudfront setup as Push CDN in multisite - Upload and Download paths are different #536

Open soubhiksaha opened 6 years ago

soubhiksaha commented 6 years ago

We are having an issue with WP Multisite’s Media Library, AWS S3, AWS Cloudfront and W3 Total Cache.

We are using WP 4.8.2, the latest version of the plugin and are using AWS Elasticbeanstalk on PHP 7.0.

Our site (example.com) uses subdirectories for multisite.

When a user uploaded a document to the library for a specific site (in this case, “nashville”), the URL was, for example: http://example.com/nashville/wp-content/uploads/sites/11/2017/03/doc.pdf

Notice the city in the URL before uploads. I am not a WP expert, but I assume this was an alias of sorts, because on disk, the file exists as [DocumentRoot]/wp-content/uploads/sites/11/2017/03/doc.pdf.

Uploads get sent to S3 and exist in the S3 bucket at “nashville”, which is at the same level as wp-content.

When the user looks at the document, they are directed to http://example.com/wp-content/uploads/sites/11/2017/03/doc.pdf (without “nashville”), which W3 Total Cache redirects to a parallel URL on Cloudfront.

So basically, the uploads go to: http://abc.cloudfront.net/nashville/wp-content/uploads/sites/11/2017/03/doc.pdf but are accessed from http://abc.cloudfront.net/wp-content/uploads/sites/11/2017/03/doc.pdf

nwisehart commented 6 years ago

I am having this same issue. Where is the code is the upload path being set?