Enable Apache Rewrite via htaccess
From zen2
Contents
1st Method
For Yii I had the problem where the rewrite in the htaccess file wasn't working
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
This was because Apache2 didn't have rewrite enabled by default, and the default site configuration had AllowOverrides set to None
First I created a symlink
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
Then
sudo gedit /etc/apache2/sites-enabled/000-default
change AllowOverride None to AllowOverride All thus:
DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
Restart Apache
sudo /etc/init.d/apache2/restart
2nd Method
From Zend setup:
Configure Apache
We need to make sure that rewrite_module is enabled in apache2 for the Zend Framework to work properly, so lets check:
a2dismod
Hopefully you should see rewrite listed in the list of modules that are currently enabled. If not, press enter to disable nothing and then issue:
a2enmod rewrite
Then we need to enable AllowOverride All in the default site file
sudo gedit /etc/apache2/sites-available/default
[...]
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory var/www/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
[...]
Restart Apache afterwards:
sudo /etc/init.d/apache2 restart
