Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable .htaccess in amazon ec2 running ubuntu

I have an instance running ubuntu in ec2. I have this .htaccess file :-

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

This file is located inside the var/www/html folder. I am aiming to achieve loading of amazon-public-dns.com/index.php as amazon-public-dns.com/index.

Now, I have tried these steps :-
1) Creating the rewrite.conf in /etc/apache2/mods-enabled and in the file putting the line LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so. (Refer this answer)
2) Running the command apache2 enable module rewrite. Also, in the file /etc/apache2/sites-available/000-default.conf and writing this in the end :-

 <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        # changed from None to FileInfo
        AllowOverride All
        Order allow,deny
        allow from all
 </Directory>

Note that this answer told to edit the default. But, since that file was not there in my case, I edited the 000-default.conf file.
I restarted apache as told. But the link amazon-public-dns.com/index gives me a 404 :( Please help me.

EDIT : I put some random junk in the htaccess file. But the index.php is not giving any 500 internal server error which means that the htaccess file is being ignored. Now in

https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles

, they say to enable htaccess edit this file - /etc/apache2/sites-available/default. BUT THERE IS NO SUCH FILE

like image 501
user4647309 Avatar asked Oct 20 '22 14:10

user4647309


1 Answers

following command works for me Great !

sudo a2enmod rewrite
sudo service apache2 restart

To check loaded modules

sudo apache2ctl -M
like image 92
Kamal Kumar Avatar answered Oct 22 '22 03:10

Kamal Kumar