【问题标题】:Images not displaying on wordpress site图片未显示在 wordpress 网站上
【发布时间】:2015-12-16 11:21:39
【问题描述】:

所有图片都在上传文件夹中。但它没有显示在前端。如果我直接打开链接,则表示找不到该图像的页面。

为什么会这样?有什么想法吗?

注意:没有安装新插件。

.htaccess文件代码:

# 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>

# END WordPress
# STRONG HTACCESS PROTECTION</code>
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>

# protect wp-config.php
<files wp-config.php>
Order deny,allow
Deny from all
</files>

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wpbeginner.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/wpbeginner [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L] 

# protect from sql injection
Options +FollowSymLinks
RewriteEngine On
#RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
#RewriteRule ^(.*)$ index.php [F,L]

【问题讨论】:

  • 您最近是否将您的网站从其他主机/环境/服务器上迁移?
  • 不在与开始时相同的位置
  • ..而且图像从未显示?还是突然消失了?
  • 突然消失
  • 嗯 :-).. 我的朋友,如果他们突然消失了,而您没有采取任何明显的行动 - 我建议您使用 FTP 并搜索它们!

标签: wordpress .htaccess security


【解决方案1】:

-这可能与位于 wp-content 文件夹中的 .htaccess 相关 > 确保它不排除任何文件类型。

-确保所有图像 chmod 设置为 644;如果不是,您可以手动修复它们或使用 ssh 命令行自动恢复文件和文件夹的默认文件权限。

命令:

找到 /path-to-website-folder -type d -exec chmod 755 {} +

找到 /path-to-website-folder -type f -exec chmod 644 {} +

  • 如果以上都不是,我建议你从 htaccess 中删除这块行:

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wpbeginner.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/wpbeginner [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L] 

检查您的 wordpress 根路径之前的其他 .htaccess 文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-30
    • 2015-12-13
    • 2017-02-25
    • 2018-08-15
    • 2014-07-19
    • 2016-10-07
    相关资源
    最近更新 更多