Problem with htaccess while using Apache and Cloudflare, and the compatibility
-
Hi,
I just installed the plugin, and, initially, I found that the WebP cannot function at all. After doing some researches, I realized that it might be the problem in my .htaccess file. So I edited the .htaccess file manually, and it works now. But I still have some confusion about the plugin setup.
My situation: Cloudflare CDN, Apache, WP Multisite
My questions are:
1. From https://docs.ewww.io/article/16-ewww-io-and-webp-images, it states that “When you enable WebP conversion, the rewrite rules will be displayed, but only if your site does not use Cloudflare.” I want to know how can Cloudflare prevent the plugin from editing the .htaccess file? The .htaccess locates in my webserver and the Cloudflare is just a CDN for my webserver right?
2. The plugin did not edit the .htaccess file for me, is it because of the Cloudflare prevention? Or is it the plugin intent to avoid editing .htaccess file because it detects I am using Cloudflare?
3. In the plugin page, it states that “Your site is using Cloudflare, please use JS WebP or <picture> WebP rewriting.” But the fact is, both JS WebP or <picture> WebP doesn’t work for me at all. I finally end up with editing .htaccess to get things to work. Why?
3. I found a discussion here: https://ww.wp.xz.cn/support/topic/the-htaccess-code-for-webp-is-wrong/ state that the current .htaccess configuration is wrong, so what is the correct one?
4. below is my current .htaccess config regarding EWWW IO (based on the video in your doc):
# BEGIN EWWWIO <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$ RewriteCond %{REQUEST_FILENAME}.webp -f RewriteCond %{QUERY_STRING} !type=original RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1] </IfModule> <IfModule mod_headers.c> Header append Vary Accept env=REDIRECT_accept </IfModule> AddType image/webp .webp # END EWWWIOIt is working, but since I added it manually, anything wrong here?
5. Regarding the rewrite rule
RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1]I however see there is another version exists:RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_URI}.webp [T=image/webp,E=accept:1,L], which added a L at the very end. Which one is correct?6. As you can see above, there is a RewriteRule:
RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1]. Although, in Chrome Inspector, the img type is webp, why the filename is still .jpg but not .jpg.webp? I suppose this RewriteRule rewrites the img url and redirect to a url end with .jpg.webp right?7. I also use easy watermark plugin. Should I add the watermark first before optimizing the image or should I optimize the image first before adding the watermark?
8. Can this plugin be used with Autoptimize together?
Sorry for the tons of questions here but I just want to make sure I properly configured the plugins.
- This topic was modified 4 years, 11 months ago by .
- This topic was modified 4 years, 11 months ago by .
- This topic was modified 4 years, 11 months ago by .
The page I need help with: [log in to see the link]
The topic ‘Problem with htaccess while using Apache and Cloudflare, and the compatibility’ is closed to new replies.