title: Yii2: Hiding frontend/web and backend/web from UrlManger
body: <p>I managed to hide <code>frontend/web</code> and <code>backend/web/</code> using .htaccess file. But the urlManager unable to understand that. I'm trying to create url like <code>site/index</code> and it should be something like this: <code>example.com/site/index</code> but it creates <code>example.com/frontend/web/site/index</code>. </p>
  
  <p>How do I solve this problem with <code>UrlManager</code>?</p>
  
  <p>Update: .htaccess in root directory.</p>
  
  <pre><code>Options -Indexes
  RewriteEngine on
  
  &lt;IfModule mod_rewrite.c&gt;
  RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
  RewriteCond %{REQUEST_URI} admin
  RewriteRule .* backend/web/index.php [L]
  
  RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/
  RewriteCond %{REQUEST_URI} !admin
  RewriteRule .* frontend/web/index.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>and here is the one I used in both <code>frontend/web</code> and <code>backend/web</code>:</p>
  
  <pre><code>RewriteEngine on
  
  # if a directory or a file exists, use the request directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # otherwise forward the request to index.php
  RewriteRule . index.php
  </code></pre>