title: Symfony Route not working Apache returning 404
body: <p>I get 404 Not Found for all request that are not /. Hitting smfony.test in the browsers opens the web page without a problem. But anything other than symfony.test will result in a 404 Not Found. I looked up several stack overflow solutions (<a href="https://stackoverflow.com/questions/20364210/symfony-routing-not-working">Issue 1</a>, <a href="https://stackoverflow.com/questions/48544786/route-is-in-debug-list-but-returns-404-in-symfony-4">Issue 2</a>), but I was not able to locate the exact problem. Seems like it has to be a misconfiguration from my side, because when I run debug:router I get all URLs:</p>
  
  <pre><code>jernej@blackbook:/var/www/html/symfart$ php bin/console debug:router
   ------------------- -------- -------- ------ -------------------------- 
    Name                Method   Scheme   Host   Path                      
   ------------------- -------- -------- ------ -------------------------- 
    _preview_error      ANY      ANY      ANY    /_error/{code}.{_format}  
    app_article_index   GET      ANY      ANY    /                         
    app_article_save    GET      ANY      ANY    /article/save             
    app_article_hello   GET      ANY      ANY    /hello                    
   ------------------- -------- -------- ------ -------------------------- 
  </code></pre>
  
  <p>Inside my project (/dir path /var/www/project/public) I also have the .htaccess file:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      # Determine the RewriteBase automatically and set it as environment variable.
      RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
      RewriteRule ^(.*) - [E=BASE:%1]
  
      # If the requested filename exists, simply serve it.
      # We only want to let Apache serve files and not directories.
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteRule .? - [L]
  
      # Rewrite all other queries to the front controller.
      RewriteRule .? %{ENV:BASE}/index.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Since I do not have a lot of experience with Apache server, I rather point out I also did the following change in the Apache configuration (/etc/apache2/sites-enabled/000-default.conf) to add project to url:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName symfony.test
      DocumentRoot /var/www/html/project/public
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I also added the URL to hosts file in linux. And here is the Controller class:</p>
  
  <pre><code>&lt;?php
  
      namespace App\Controller;
  
      use App\Entity\Article;
  
      use Symfony\Component\HttpFoundation\Response;
      use Symfony\Component\Routing\Annotation\Route;
      use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  
      class ArticleController extends AbstractController {
  
          /**
           * @Route("/", methods={"GET"})
           */
          public function index() {
              $articles = array();
  
              return $this-&gt;render('articles/index.html.twig', array('articles' =&gt; $articles));
          }
  
          /**
           * @Route("/article/save", methods={"GET"})
           */
          public function save() {
              $entityManager = $this-&gt;getDoctrine()-&gt;getManager();
  
              $article = new Article();
              $article-&gt;setTitle('Article One');
              $article-&gt;setBody('This is the body for article one');
  
              $entityManager-&gt;persist($article);
              $entityManager-&gt;flush();
  
              return new Response('Saved an article with the id of ' + $article-&gt;getId());
          }
  
          /**
           * @Route("/hello", methods={"GET"})
           */
          public function hello() {
              $articles = array();
  
              return $this-&gt;render('articles/index.html.twig', array('articles' =&gt; $articles));
          }
      }
  
  ?&gt;
  </code></pre>