The mod_rewrite rule is not working on the virtual host. I have wanted this for cakephp.
Is there setting to add in the virtual host file?
If you are using latest apache version 2.4+ then here is the process how to enable mod_rewrite.
Go to etc/apache2/
Open apache2.conf
using your favorite text editor.
Change
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then save it. Remember you should have root permission to edit and save this file.
Now restart apache.
service apache2 reload
This process will enable mod_rewrite for apache server including virtual host.
You can also check if it's enabled or not. Create a php script
<?php
phpinfo();
?>
Load it from server. Under Loaded Modules
section check if mod_rewrite
is there or not. If it's there then it is enabled.
apache2.conf
and restarting apache
404 disappeared but all pages landed back on homepage! phpinfo()
did not have mod_rewrite
module enabled either. Then running CLI commnd (as suggested by Lonston below) everything gone golden! Why this solution did not enable mod-rewrite
module for me but the CLI approad? Is this a combination of modifying .conf
and running CLI command one after another to enable the module or either of these is actually enough?
Jul 1, 2016 at 9:47
Enable Rewrite using
# sudo a2enmod rewrite
Then restart the apcahe2 using
# service apache2 restart
Enable in Virtualhost by adding
AllowOverride FileInfo
Then restart the apcahe2 using
# service apache2 restart
example:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# I Have below line from none to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>