Redirect requests using .htaccess and mod_rewrite

  1. Make sure Apache .htaccess is enabled (by default it is enabled in Ubuntu)
  2. Make sure the Apache module mod_rewrite is enabled. Execute:

sudo a2enmod rewrite

..and see if rewrite is listed here:

sudo apache2ctl -M

and then you can redirect requests using RewriteRules. Example:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_REQUEST=$1 [L]

Check your apache.conf

<Directory /var/www/html/>
 Options Indexes FollowSymLinks 
 AllowOverride All
 Require all granted