Apache does not have mod_rewrite enabled by default so for you need to install rewrite module in Apache server using below command,

$ sudo a2enmod rewrite 

Then, add or edit 'AllowOverride All' in  /etc/apache2/apache2.conf file or VirtualHost,

Sample configuration line in VirtualHost,
 <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

Finally, Restart your apache server:

 $ sudo service apache2 restart 

I hope so, the problem will be solved.