Yii2 .htaccess prevent to access images in backend
<p>I have .htaccess file in my yii2 root directory to hide frontend/web and I'm uploading images in yii2-app/uploads.
Issue is I can't access images in backend due to this line <code>RewriteRule ^(.*)$ frontend/web/$1 [L]</code> , if I delete this line then images are accessible but frontend/web appears in url, How I can solve this? How I can create a special rule for access images?</p>

<p>In grid view:</p>

<pre><code>[
 'label' =&gt; 'Image', 
 'attribute' =&gt; 'banner', 
 'format' =&gt; 'raw',   
 'value' =&gt; function ($data) {
      return Html::img(Yii::$app-&gt;request-&gt;baseUrl.'../../../uploads/'.$data-&gt;banner, ['alt'=&gt;$data-&gt;title,'width'=&gt;'20','height'=&gt;'30']); 
   }
],   
</code></pre>

<p>.htaccess:</p>

<pre><code>Options -Indexes

&lt;IfModule mod_rewrite.c&gt; 
  RewriteEngine on
  #RewriteCond %{REQUEST_URI} !^public
  RewriteRule ^(.*)$ frontend/web/$1 [L] 
&lt;/IfModule&gt;

# Deny accessing below extensions
&lt;Files ~ "(.json|.lock|.git)"&gt;
Order allow,deny
Deny from all
&lt;/Files&gt;

# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
</code></pre>

<p>Directory structure:</p>

<pre><code>yii2-app
   --backend
   --frontend
   --uploads
</code></pre>