<VirtualHost *:80>
  ServerAdmin admin@localhost
  ServerName app
  #ServerAlias www.app
  DocumentRoot /var/www/app

 <Directory /var/www/app>
    Options FollowSymLinks
    AllowOverride None
    AddDefaultCharset utf-8
    DirectoryIndex index.php
    Require all granted
    <IfModule mod_rewrite.c>
        RewriteEngine On

        # Merge slashes "//" to "/"
        RewriteCond %{THE_REQUEST} .*\ (.*)//(.*)\ HTTP/
        RewriteRule .* %1/%2 [R=301,L]

        # Redirect /index.php to /
        RewriteCond %{THE_REQUEST} ^.*\ /index\.(?:php|htm|html)(\?.*)?\ HTTP/
        RewriteRule ^.*$ /%1 [R=301,L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    </IfModule>
  </Directory>
</VirtualHost>