htaccess works in localhost but doesn't work in EC2 instance
I pieced together some info from various posts so I thought I'd put up an answer.
- As Paul commented, If you're running Amazon EC2 Linux, you're probably running httpd instead of Apache. The file is therefore in
/etc/httpd/conf/httpd.conf
- You have to change the file as root user. (from ssh access) Do this:
sudo vim /etc/httpd/conf/httpd.conf
(How to edit httpd.conf file in AMAZON EC2) DocumentRoot "/var/www/html"
was listed in two places for me. I had to change the subsequentAllowOverride None
toAllowOverride All
in those two places.- Restart apache. I restarted my whole ec2 instance (i have apache configured to start automatically) although just restarting apache should work. But I see the change is working.
I was trying to make the same changes in a .htaccess file (removing the index.php from urls in a code igniter application). Hope it helps!
By default EC2 doesn't have .htaccess enabled, you must edit your httpd.config to allow for it.
In /etc/apache/sites-available/default change AllowOverRide = None to AllowOverRide = All.
Its a three step process
Configure apache mod_rewrite,run in terminal.sudo a2enmod rewrite
add the following code to /etc/apache2/sites-available/default
DocumentRoot /var/www<Directory />Options FollowSymLinksAllowOverride All</Directory><Directory /var/www/>Options Indexes FollowSymLinks MultiViewsAllowOverride AllOrder allow,denyallow from all</Directory>
3.Restart apache
/etc/init.d/apache2 restart