title: Yii2:-Pretty URL's are formed, but not working (says 404 NOT FOUND)
body: <p>I have started learning yii2 and I tried to do pretty URL stuff, but failed. What I did:-</p>
  
  <p><strong>in config/web.php (I have edited below):</strong></p>
  
  <pre><code>'urlManager' =&gt; [
          'class' =&gt; 'yii\web\UrlManager',
          // Hide index.php
          'showScriptName' =&gt; false,
          // Use pretty URLs
          'enablePrettyUrl' =&gt; true,
          'rules' =&gt; [
          ],
  </code></pre>
  
  <p><strong><em>then I have created a <code>.htaccess</code> file and put it on root (it has below code):</em></strong></p>
  
  <pre><code>RewriteEngine on
  
  # if a directory or a file exists, use it directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # otherwise forward it to index.php
  RewriteRule . index.php
  </code></pre>
  
  <p><strong>Also I had opened apache2.conf file and changed like this:</strong></p>
  
  <pre><code>&lt;Directory /var/www/&gt;
      Options Indexes FollowSymLinks
      AllowOverride All &lt;! -- instead of none --&gt;
      Require all granted
  &lt;/Directory&gt;
  </code></pre>
  
  <p><strong><em>Also I checked the changes through the command:</em></strong></p>
  
  <pre><code> grep -R AllowOverride /etc/apache2
  </code></pre>
  
  <p><strong><em>And it shows like below:</em></strong></p>
  
  <pre><code>/etc/apache2/apache2.conf:  AllowOverride All  &lt;!-- It is showing that done --&gt;
  </code></pre>
  
  <p><strong>Now:</strong></p>
  
  <p><strong><em>when I access my page through:</em></strong></p>
  
  <p><a href="http://localhost/yii2/web/" rel="nofollow noreferrer">http://localhost/yii2/web/</a></p>
  
  <p>it's opened and when I hover on any link of the page,it showed me something like this: <a href="http://localhost/yii2/web/site/about" rel="nofollow noreferrer">http://localhost/yii2/web/site/about</a>  (which shows that pretty URL's maid)</p>
  
  <p>But these URL's are not working (says 404 found)</p>
  
  <p><strong><em>I have tried below posts code also, but didn't worked for me:</em></strong> </p>
  
  <p><a href="https://stackoverflow.com/questions/38715473/how-to-access-a-controller-with-pretty-url-in-yii2">How to access a controller with pretty url in Yii2</a></p>
  
  <p><a href="https://stackoverflow.com/questions/26525320/enable-clean-url-in-yii2">Enable clean URL in Yii2</a></p>