I'm while using readfile function to see image files. It really works generally except when a picture is situated inside a directory with htaccess file.

Here's a good example:

header("Content-type: image/jpeg");
ob_clean(); // clean output buffer
flush(); // flush output buffer 
readfile("http://127.0.0.1/WebProjects/project1/data/media/images/original/7.jpg");
exit;

The htaccess is situated within the http://127.0.0.1/WebProjects/project1/ directory and appears such as this:

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

In whatever way ways to get for this? The htaccess file should be there since the web application for the reason that folder needs results.

Why don't you browse the file from the filesystem rather than studying the web server?

readfile("/srv/WebProjects/project1/data/media/images/original/7.jpg");

What's most likely is your images read permissions for apache but no read permissions for whomever PHP runs as.

Try setting the permissions from the image to 0644.

RewriteCond %{REMOTE_ADDR}="127.0.0.1"

Use REMOTE_ADDR like a new RewriteCond before others to skip them. Because you professional code is local it will likewise be from 127...1 and really should undergo nicely.