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
following command works for me Great !
sudo a2enmod rewrite
sudo service apache2 restart
To check loaded modules
sudo apache2ctl -M
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With