Navnish Bhardwaj
Navnish Bhardwaj

Reputation: 1718

Images not displaying on wordpress site

All images are in uploads folder. But its not displaying on front end. And if I am opening link directly it's saying page not found for that image.

Why so? Any idea?

Note: no new plugins are installed.

.htaccess file code:

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

Upvotes: 0

Views: 968

Answers (1)

-This can be related to .htaccess located in wp-content folder > Make sure It doesn't exclude any file type.

-Make sure all the images chmod are set to 644; If they are not, You can either fix them manually or use ssh commands lines to automatically restore default file permissions for files & folders.

Commands:

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

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

  • If none of the above, I recommend you to remove this chunk of lines from 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] 

Check other .htaccess files preceding the your wordpress root path

Upvotes: 1

Related Questions