• Resolved stkontra

    (@stkontra)


    Hi Mateusz,
    First of all many thanks for the plugin.
    I successfully converted all the images, but the site not loading them.
    I followed all the instructions in FAQ plus tried some of the support forum posts.
    Server: https://babamancs.hu/01-screencapture-babamancs-hu-wp-admin-options-general-php-2020-01-09-12_49_31.pdf

    htaccess file:
    AddType image/webp .webp
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # BEGIN WebP Converter
    <IfModule mod_mime.c>
    AddType image/webp .webp
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpg.webp -f
    RewriteRule (.+)?uploads/(.+)\.jpg$ $1/uploads-webpc/$2.jpg.webp [T=image/webp]
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpeg.webp -f
    RewriteRule (.+)?uploads/(.+)\.jpeg$ $1/uploads-webpc/$2.jpeg.webp [T=image/webp]
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.png.webp -f
    RewriteRule (.+)?uploads/(.+)\.png$ $1/uploads-webpc/$2.png.webp [T=image/webp]
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp “access plus 1 year”
    </IfModule>
    # END WebP Converter

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter stkontra

    (@stkontra)

    `add_filter(‘webpc_uploads_path’, function($path) {
    return ‘wp-content/uploads/’;
    });

    add_filter(‘webpc_uploads_webp’, function($path) {
    return ‘wp-content/uploads-webpc’;
    });

    Thread Starter stkontra

    (@stkontra)

    add_filter('webpc_uploads_path', function($path) {
      return 'wp-content/uploads/';
    });
    
    add_filter('webpc_uploads_webp', function($path) {
      return 'wp-content/uploads-webpc';
    });
    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Your server is nginx, right? Does he “read” the rules contained in the .htaccess file?

    Thread Starter stkontra

    (@stkontra)

    Hi Mateusz,
    Thanks for your quick reply.
    Yes, it’s apache+nginx+varnish
    So, what is missing from the htaccess?

    AddType image/webp .webp
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # BEGIN WebP Converter
    <IfModule mod_mime.c>
      AddType image/webp .webp
    </IfModule>
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpg.webp -f
      RewriteRule (.+)?uploads/(.+)\.jpg$ $1/uploads-webpc/$2.jpg.webp [T=image/webp]
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpeg.webp -f
      RewriteRule (.+)?uploads/(.+)\.jpeg$ $1/uploads-webpc/$2.jpeg.webp [T=image/webp]
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.png.webp -f
      RewriteRule (.+)?uploads/(.+)\.png$ $1/uploads-webpc/$2.png.webp [T=image/webp]
    </IfModule>
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresByType image/webp "access plus 1 year"
    </IfModule>
    # END WebP Converter
    Thread Starter stkontra

    (@stkontra)

    Ok, yes, I have this in the nginx server configuration:

    location ~ (?<root>.+)/uploads/(?<path>.+)\.(?<ext>jp?g|png|gif)$ {
        if ($http_accept !~* "image/webp") {
          break;
        }
        add_header Vary Accept;
        expires 365d;
        try_files $root/wp-content/uploads-webpc/$path.$ext.webp $uri =404;
      }
    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    It looks like your Redirect rules are not working.

    Can you contact your Administrator and ask him why the server does not understand these rules?

    Thread Starter stkontra

    (@stkontra)

    Do I need the /wp-content from of the uploads in the code?

    location ~ (?<root>.+)/wp-content/uploads/(?<path>.+)\.(?<ext>jp?g|png|gif)$ {
        if ($http_accept !~* "image/webp") {
          break;
        }
        add_header Vary Accept;
        expires 365d;
        try_files $root/wp-content/uploads-webpc/$path.$ext.webp $uri =404;
      }	
    	
    Thread Starter stkontra

    (@stkontra)

    Sorry there is a typo in the previous post:
    Do I need the /wp-content front of the uploads…

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Looking at the content of your .htaccess file, you have an old version of the plugin. Can you update it and check it again?

    Send me the contents of the .htaccess file again.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘All files converted but not loading’ is closed to new replies.