-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webp .htaccess not working #45
Comments
Thank you very much for your feedback!
That's strange, this rule should not be required since the .htaccess should never reach October's PHP blacklist rules. I have updated the rules a bit, would you mind testing if this works on your server (without the explicit whitelisting of the webp.php?) If I remove the |
The latest updates work. But only worked with the So we need to use the It works using:
Other point: It's important to only match the storage folder. For example. My theme images are now always served using
which is not a good thing to do. These files should just be served static. |
Wow, thank you for this input! I did not know about the <ifModule mod_rewrite.c>
RewriteEngine On
# If the Browser supports WebP images, and the .webp file exists, use it.
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} ^/?storage/.*\.(jpe?g|png)
RewriteCond %{REQUEST_FILENAME}.webp -f
RewriteRule ^/?(.*)$ $1.webp [NC,T=image/webp,END]
# If the Browser supports WebP images, and the .webp file does not exist, generate it.
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} ^/?storage/.*\.(jpe?g|png)
RewriteCond %{REQUEST_FILENAME}\.webp !-f
RewriteRule ^/?(.*)$ %{DOCUMENT_ROOT}/plugins/offline/responsiveimages/webp.php?path=$1 [NC,END]
</ifModule> |
Yep this is it 😃 . Works great! |
I also made a further little change to my project rules which makes sure only resized images are served as webp ( |
I think the main problem is, that the plugin creates a new file with the file extension itself. For example
The plugin should create the new file without the jpg extension. I added a webp extension rule to exclude this case like so:
|
I'm drawing a blank. I currently fail to see the problem. The frontend will issue a request for Where do things go wrong? |
Thats working great and is not the problem :) |
First thanks for the amazing work!
I could not get the webp .htaccess rules working. I had to add the following lines to some existing OctoberCMS rules:
Without this apache2 would parse all the rules multiple times. I even had situations I reached the max 10 internal redirects.
I also had alot of issues with the DOCUMENT_ROOT rewrites (slash issues, I think dependend on how the document_root is set invhost). Eventually I picked the rules from the Wordpress webp express plugin:
With these changes everything worked perfectly! :)
Hope you understand the issues I have had and find it useful to improve things.
My full .htaccess:
The text was updated successfully, but these errors were encountered: