.htaccess 10月CMS插件webp转换404错误
.htaccess 404 error with webp conversion in October CMS plug-in
在 October CMS 中使用第三方插件(“ResponsiveImages”)时遇到问题。该插件将图像转换为 webp
。一些图像被转换,而其他图像 - 没有。其中一些我得到了 error 404
代码。图片也不会显示在博客组件的后端。
如果我尝试直接访问图像 - 指定了 No input file specified
错误。 system.log
为空。
我已将开发人员推荐的规则添加到 .htaccess
,现在它看起来像这样:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
RewriteBase /
##
## Uncomment following lines to force HTTPS.
##
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/ [L,R=301]
<IfModule mod_setenvif.c>
# Vary: Accept for all the requests to jpeg and png
SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image
</IfModule>
# 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 ^/?(.*)$ .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 ^/?(.*)$ plugins/offline/responsiveimages/webp.php?path= [NC,END]
<IfModule mod_headers.c>
Header append Vary Accept env=REQUEST_image
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
##
## White listed folders
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !^/plugins/vdlp/phast/phast\.php*
RewriteCond %{REQUEST_FILENAME} !/.well-known/*
RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/.*
RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.*
RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.*
RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.*
RewriteRule !^index.php index.php [L,NC]
##
## Block all PHP files, except index
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !^/plugins/vdlp/phast/phast\.php*
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule !^index.php index.php [L,NC]
##
## Standard routes
##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
如果我删除此行 RewriteRule ^/?(.*)$ plugins/offline/responsiveimages/webp.php?path= [NC,END]
- 将跳过插件工作并显示默认图像。
这是 html
的一部分,其中没有显示图像:
<div class="owl-item active" style="width: 264.8px;">
<div>
<div class="hero-item portfolio-item set-bg" data-setbg="https://www.website.com/storage/app/uploads/public/5ff/742/879/5ff7428794d80134665311.jpg" style="background-image: url("https://www.filmustudija.lt/storage/app/uploads/public/5ff/742/879/5ff7428794d80134665311.jpg"); width: 321px; height: 321px;">
<a href="https://www.website.com/post/post" class="hero-link">
<h2>Heading</h2>
</a>
</div>
</div>
</div>
您可以使用此插件将图像转换为 webp https://octobercms.com/plugin/toughdeveloper-imageresizer
{{ property.image | resize(500, false, { mode: 'crop', quality: '80', extension: 'webp' }) }}
或文件模型对象的标准方法 getThumb()
{{ obModel.avatar.getThumb(500, false, { mode: 'crop', quality: '80', extension: 'webp' }) }}
开箱即用
真是奇怪的问题。
首先,我使用了 gitHub 上发现的稍微过时的 .htaccess
。
然后,一旦创建了所有图像,我就回滚到原始 .htaccess
。
现在一切正常。
在 October CMS 中使用第三方插件(“ResponsiveImages”)时遇到问题。该插件将图像转换为 webp
。一些图像被转换,而其他图像 - 没有。其中一些我得到了 error 404
代码。图片也不会显示在博客组件的后端。
如果我尝试直接访问图像 - 指定了 No input file specified
错误。 system.log
为空。
我已将开发人员推荐的规则添加到 .htaccess
,现在它看起来像这样:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
RewriteBase /
##
## Uncomment following lines to force HTTPS.
##
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/ [L,R=301]
<IfModule mod_setenvif.c>
# Vary: Accept for all the requests to jpeg and png
SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image
</IfModule>
# 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 ^/?(.*)$ .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 ^/?(.*)$ plugins/offline/responsiveimages/webp.php?path= [NC,END]
<IfModule mod_headers.c>
Header append Vary Accept env=REQUEST_image
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
##
## White listed folders
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !^/plugins/vdlp/phast/phast\.php*
RewriteCond %{REQUEST_FILENAME} !/.well-known/*
RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/.*
RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.*
RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.*
RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.*
RewriteRule !^index.php index.php [L,NC]
##
## Block all PHP files, except index
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !^/plugins/vdlp/phast/phast\.php*
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule !^index.php index.php [L,NC]
##
## Standard routes
##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
如果我删除此行 RewriteRule ^/?(.*)$ plugins/offline/responsiveimages/webp.php?path= [NC,END]
- 将跳过插件工作并显示默认图像。
这是 html
的一部分,其中没有显示图像:
<div class="owl-item active" style="width: 264.8px;">
<div>
<div class="hero-item portfolio-item set-bg" data-setbg="https://www.website.com/storage/app/uploads/public/5ff/742/879/5ff7428794d80134665311.jpg" style="background-image: url("https://www.filmustudija.lt/storage/app/uploads/public/5ff/742/879/5ff7428794d80134665311.jpg"); width: 321px; height: 321px;">
<a href="https://www.website.com/post/post" class="hero-link">
<h2>Heading</h2>
</a>
</div>
</div>
</div>
您可以使用此插件将图像转换为 webp https://octobercms.com/plugin/toughdeveloper-imageresizer
{{ property.image | resize(500, false, { mode: 'crop', quality: '80', extension: 'webp' }) }}
或文件模型对象的标准方法 getThumb()
{{ obModel.avatar.getThumb(500, false, { mode: 'crop', quality: '80', extension: 'webp' }) }}
开箱即用
真是奇怪的问题。
首先,我使用了 gitHub 上发现的稍微过时的 .htaccess
。
然后,一旦创建了所有图像,我就回滚到原始 .htaccess
。
现在一切正常。