title: Proper way to set up apache2 default config and htaccess in project directory
body: <p>Dear people,</p>
  
  <p><strong>My goal</strong> is to set up the apache2's <code>000-default.conf</code> and the <code>.htaccess</code> in a specific way, so the user will always be redirected to a specific php file (<code>index.php</code> for example) if they (the user) wants to access the web app, which I am building.</p>
  
  <p>Examples :</p>
  
  <ul>
  <li>example-app.local </li>
  <li>example-app.local/hello-world</li>
  <li>example-app.local/admin.php</li>
  <li>example-app-local/../../../../my-passwords.txt</li>
  </ul>
  
  <p>All of them should point to <code>index.php</code>. I followed several tutorials, but I guess I need a specific tutorial for me, so that I can fully understand the concepts of apache2 and its configurations. Feel free to judge me - I am alright with criticism.</p>
  
  <p><strong>What I have in my files</strong> is the following</p>
  
  <p><em>1. The 000-default.conf file which is located in /etc/apache2/sites-available/</em></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
     &lt;Directory /var/www/&gt;
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
     &lt;/Directory&gt;
  
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><em>...and loads of comments</em></p>
  
  <p><em>2. The example-app.local.conf file which is located in /etc/apache2/sites-available/</em></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
     ServerAdmin admin@example.com
     ServerName example-app.local
     ServerAlias www.example-app.local
     DocumentRoot "/var/www/example-app"
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><em>3. The .htaccess file which is located in /var/www/example-app/</em></p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule ^(.*)$ /index.php?url=$1 [QSA,R]
  </code></pre>
  
  <p><strong>What I get</strong> is the following : "Apache default conf is like a god of the configurations and you can state specifically that you can <code>AllowRedirect</code> which will magically trigger the functionality of <code>htaccess</code> and there you need the even more magical syntax to make every request from the user point ONLY to the index.php" Is this correct?</p>
  
  <p><strong>What is working</strong> Apache is working. I am enabling and disabling configs via</p>
  
  <pre><code> sudo a2ensite 000-default.conf
   sudo a2dissite 000-default.conf
  </code></pre>
  
  <p>and then I restart and check that everything is fine via</p>
  
  <pre><code>sudo service apache2 restart
  sudo service apache2 status
  </code></pre>
  
  <p>the status states <code>active (running)</code>.</p>
  
  <p>The content of <code>/etc/hosts</code> is also edited in a correct way, because I can actually see the content of the <code>index.html</code> file when I try to point my browser to the <code>example-app.local</code> page. I would also like to point out that I have php installed correctly - I tested it via the <code>phpinfo</code> function/method. </p>
  
  <p>I tried several tutorials and none of them helped me. I believe I am missing something important and I am too 'blind' to see it, so I need someone to 'open' my eyes, so please - help me.</p>
  
  <p>Best regards,</p>
  
  <p>Yet another confused startup developer,</p>
  
  <p>Bobkoo</p>