how to remove index.php from yii2 and apache2
#paste this in your terminal
sudo a2enmod rewrite
sudo service apache2 restart
#add the line below to /etc/apache2/sites-enabled/000-default.conf
<Directory /var/www/html>
AllowOverride All
</Directory>
#create file .htaccess within web dir, paste the lines below into the file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>