WordPress不在所有浏览器中显示图像

时间:2017-08-10 18:03:47

标签: wordpress image

我的非商业网站danijelaenjoriskoken.nl有一个奇怪的问题。

在许多系统上,它完美地展示了所有图像。

但是,有几个系统(大约25%的已知系统)不显示图像,只有一个空白矩形,中间有一个小图像图标。但是,如果右键单击此矩形并选择“查看图像”,则会显示正确的图像。返回原始页面,图像突然显示出来。在刷新页面之前......这会导致图像再次消失。

我无法弄清楚浏览器显示与不显示图像之间的差异:

  1. 我可以在我的Android手机,我的Mac书,我的Windows笔记本电脑和桌面(IE,Edge,Safari和Chrome)上看到图像
  2. 我无法在Android平板电脑上看到这些图片。没有看到图像的朋友正在使用iPhone 5和6,Mac书籍,Windows桌面。
  3. 它不是一个简单的权利问题,因为尽管您必须先直接查看图像,但每个系统都可以查看图像。

    查看之后,它可以显示在页面中...直到你重新加载,就像它是由于一些缓存它显示在页面中。但这意味着WordPress总是知道图像的正确位置。

    我在Google网站上搜索并搜索过,但由于权利不正确,编码错误,媒体库不正确等原因,我只能找到有关完全丢失图片的问题。

    更新1 问题似乎是由url中的www引起的(请参阅注释)。

    我安装了WP安全模块,它有一个复制保护选项,但是没有检查。

    我检查了.htaccess,但我无法自己解决。这是内容:

    
        # BEGIN All In One WP Security
        #AIOWPS_BASIC_HTACCESS_RULES_START
        
        
        Require all denied
        
        
        Order deny,allow
        Deny from all
        
        
        ServerSignature Off
        LimitRequestBody 10240000
        
        
        Require all denied
        
        
        Order deny,allow
        Deny from all
        
        
        #AIOWPS_BASIC_HTACCESS_RULES_END
        #AIOWPS_PINGBACK_HTACCESS_RULES_START
        
        
        Require all denied
        
        
        Order deny,allow
        Deny from all
        
        
        #AIOWPS_PINGBACK_HTACCESS_RULES_END
        #AIOWPS_DEBUG_LOG_BLOCK_HTACCESS_RULES_START
        
        
        Require all denied
        
        
        Order deny,allow
        Deny from all
        
        
        #AIOWPS_DEBUG_LOG_BLOCK_HTACCESS_RULES_END
        #AIOWPS_DISABLE_INDEX_VIEWS_START
        Options -Indexes
        #AIOWPS_DISABLE_INDEX_VIEWS_END
        #AIOWPS_DISABLE_TRACE_TRACK_START
        
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
        RewriteRule .* - [F]
        
        #AIOWPS_DISABLE_TRACE_TRACK_END
        #AIOWPS_FORBID_PROXY_COMMENTS_START
        
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^POST
        RewriteCond %{HTTP:VIA} !^$ [OR]
        RewriteCond %{HTTP:FORWARDED} !^$ [OR]
        RewriteCond %{HTTP:USERAGENT_VIA} !^$ [OR]
        RewriteCond %{HTTP:X_FORWARDED_FOR} !^$ [OR]
        RewriteCond %{HTTP:X_FORWARDED_HOST} !^$ [OR]
        RewriteCond %{HTTP:PROXY_CONNECTION} !^$ [OR]
        RewriteCond %{HTTP:XPROXY_CONNECTION} !^$ [OR]
        RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
        RewriteCond %{HTTP:HTTP_CLIENT_IP} !^$
        RewriteRule wp-comments-post\.php - [F]
        
        #AIOWPS_FORBID_PROXY_COMMENTS_END
        #AIOWPS_DENY_BAD_QUERY_STRINGS_START
        
        RewriteEngine On
        RewriteCond %{QUERY_STRING} ftp:     [NC,OR]
        RewriteCond %{QUERY_STRING} http:    [NC,OR]
        RewriteCond %{QUERY_STRING} https:   [NC,OR]
        RewriteCond %{QUERY_STRING} mosConfig [NC,OR]
        RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
        RewriteCond %{QUERY_STRING} (\;|'|\"|%22).*(request|insert|union|declare|drop) [NC]
        RewriteRule ^(.*)$ - [F,L]
        
        #AIOWPS_DENY_BAD_QUERY_STRINGS_END
        #AIOWPS_SIX_G_BLACKLIST_START
        # 6G FIREWALL/BLACKLIST
        # @ https://perishablepress.com/6g/
    
        # 6G:[QUERY STRINGS]
        
        RewriteEngine On
        RewriteCond %{QUERY_STRING} (eval\() [NC,OR]
        RewriteCond %{QUERY_STRING} (127\.0\.0\.1) [NC,OR]
        RewriteCond %{QUERY_STRING} ([a-z0-9]{2000,}) [NC,OR]
        RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]
        RewriteCond %{QUERY_STRING} (base64_encode)(.*)(\() [NC,OR]
        RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC,OR]
        RewriteCond %{QUERY_STRING} (|%3) [NC,OR]
        RewriteCond %{QUERY_STRING} (\|\.\.\.|\.\./|~|`||\|) [NC,OR]
        RewriteCond %{QUERY_STRING} (boot\.ini|etc/passwd|self/environ) [NC,OR]
        RewriteCond %{QUERY_STRING} (thumbs?(_editor|open)?|tim(thumb)?)\.php [NC,OR]
        RewriteCond %{QUERY_STRING} ('|\")(.*)(drop|insert|md5|select|union) [NC]
        RewriteRule .* - [F]
        
    
        # 6G:[REQUEST METHOD]
        
        RewriteCond %{REQUEST_METHOD} ^(connect|debug|move|put|trace|track) [NC]
        RewriteRule .* - [F]
        
    
        # 6G:[REFERRERS]
        
        RewriteCond %{HTTP_REFERER} ([a-z0-9]{2000,}) [NC,OR]
        RewriteCond %{HTTP_REFERER} (semalt.com|todaperfeita) [NC]
        RewriteRule .* - [F]
        
    
        # 6G:[REQUEST STRINGS]
        
        RedirectMatch 403 (?i)([a-z0-9]{2000,})
        RedirectMatch 403 (?i)(https?|ftp|php):/
        RedirectMatch 403 (?i)(base64_encode)(.*)(\()
        RedirectMatch 403 (?i)(=\'|=\%27|/\'/?)\.
        RedirectMatch 403 (?i)/(\$(\&)?|\*|\"|\.|,|&|&?)/?$
        RedirectMatch 403 (?i)(\{0\}|\(/\(|\.\.\.|\+\+\+|\\"\\")
        RedirectMatch 403 (?i)(~|`||:|;|,|%|\|\s|\{|\}|\[|\]|\|)
        RedirectMatch 403 (?i)/(=|\$&|_mm|cgi-|etc/passwd|muieblack)
        RedirectMatch 403 (?i)(&pws=0|_vti_|\(null\)|\{\$itemURL\}|echo(.*)kae|etc/passwd|eval\(|self/environ)
        RedirectMatch 403 (?i)\.(aspx?|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rar|rdf)$
        RedirectMatch 403 (?i)/(^$|(wp-)?config|mobiquo|phpinfo|shell|sqlpatch|thumb|thumb_editor|thumbopen|timthumb|webshell)\.php
        
    
        # 6G:[USER AGENTS]
        
        SetEnvIfNoCase User-Agent ([a-z0-9]{2000,}) bad_bot
        SetEnvIfNoCase User-Agent (archive.org|binlar|casper|checkpriv|choppy|clshttp|cmsworld|diavol|dotbot|extract|feedfinder|flicky|g00g1e|harvest|heritrix|httrack|kmccrew|loader|miner|nikto|nutch|planetwork|postrank|purebot|pycurl|python|seekerspider|siclab|skygrid|sqlmap|sucker|turnit|vikspider|winhttp|xxxyy|youda|zmeu|zune) bad_bot
    
        # Apache 
        Order Allow,Deny
        Allow from all
        Deny from env=bad_bot
        
    
        # Apache >= 2.3
        
        
        Require all Granted
        Require not env bad_bot
        
        
        
        #AIOWPS_SIX_G_BLACKLIST_END
        #AIOWPS_BLOCK_SPAMBOTS_START
        
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} POST
        RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
        RewriteCond %{HTTP_REFERER} !^http(s)?://danijelaenjoriskoken\.nl [NC,OR]
        RewriteCond %{HTTP_USER_AGENT} ^$
        RewriteRule .* http://127.0.0.1 [L]
        
        #AIOWPS_BLOCK_SPAMBOTS_END
        #AIOWPS_PREVENT_IMAGE_HOTLINKS_START
        
        RewriteEngine On
        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
        RewriteCond %{HTTP_REFERER} !^http(s)?://danijelaenjoriskoken\.nl [NC]
        RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]
        
        #AIOWPS_PREVENT_IMAGE_HOTLINKS_END
        # END All In One WP Security
    
        # BEGIN WordPress
        
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        
    
        # END WordPress
    
    

3 个答案:

答案 0 :(得分:2)

您网站上的图片也未在我的机器上显示(Windows 10)。检查员显示图像的以下错误:

  

无法加载资源:服务器响应状态为403   (禁止)

这听起来像是一个许可问题。检查这些图像的文件权限。它们应该是644。

<强>更新

现在我注意到如果我使用 www 访问该网站,则图片不起作用: http://www.danijelaenjoriskoken.nl/

但如果我在没有www的情况下访问网站,那么图片就可以了:

http://danijelaenjoriskoken.nl/

所以我认为 .htaccess 文件,某个插件或服务器启用了“阻止热链接”功能,这就是问题的原因。

更新2:

另外注意到,一旦我使用http://danijelaenjoriskoken.nl/加载siter并且图像显示,如果我再使用 www 加载它,图像就会正常工作,问题就会消失。

答案 1 :(得分:1)

我不明白'www'来自何处,我认为应首先理解。但作为最后的手段,您可以添加

RewriteCond %{HTTP_HOST}   www\.danijelaenjoriskoken\.nl [NC]
RewriteRule ^/(.*)         http://danijelaenjoriskoken.nl/$1 [L,R]

这应该将www.danijelaenjoriskoken.nl重写为danijelaenjoriskoken.nl

此答案的信用证属于user8230352 ,他们发现了此问题的关键特征。我试图将其添加为注释,但它无法正确格式化。

答案 2 :(得分:1)

User8230352的特征是正确的(www与非www)。

User8262086在重写规则中几乎是正确的。

重写规则必须是:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.danijelaenjoriskoken\.nl [NC]
RewriteRule ^(.*)$ http://danijelaenjoriskoken.nl/$1 [L,R=301]

这些规则位于文件顶部,由于已删除的网址,网站显示正确。

这解决了这些症状。

然而,感谢并给出了给定答案的启发,我禁用了模块WP All in One Security,以找出问题的根本原因。

禁用模块后,一堆代码从.htaccess中消失了。我还删除了上面自己的重写规则。现在,WordPress确实显示图像,即使使用www前缀网址。

由于我确实希望获得一些垃圾邮件保护,我再次激活模块以测试导致问题的设置......仍在寻找... .htaccess保持平稳和干净,只是一些规则。

似乎不知何故.htaccess被如此严厉地搞乱,或者说有矛盾的规则,该网站无法与之合作。