Codeigniter.htaccess in amazon ec2 removing index.php not working

Codeigniter .htaccessin amazon ec2 removing index.php not working

code

RewriteEngine on
RewriteBase http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

configuration file

$config['base_url'] = 'http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/';
+1
source share
4 answers

You can change .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

and change the AllowOverride None "to /etc/httpd/conf/httpd.conf (if you are using AMI Linux)

in " AllowOverride All "

after that restart your apache with the command as follows:

sudo service httpd restart

It works and is tested on my aws ec2.

+10
source

Yududin is right!

" AllowOverride All" ; /etc/httpd/conf/httpd.conf - :

<Directory "/var/www/your_website">
    AllowOverride All
</Directory>
+3
(if you use ubuntu)
Activate the mod_rewrite module with

     sudo a2enmod rewrite

and restart the apache

     sudo service apache2 restart

To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with

     sudo nano /etc/apache2/sites-available/000-default.conf

Search for "DocumentRoot /var/www/html" and add the following lines directly below:

    <Directory "/var/www/html">
        AllowOverride All
    </Directory>

Save and exit the nano editor via CTRL-X, "y" and ENTER.

Restart the server again:

     sudo service apache2 restart
+1

Only you can use the "AllowOverride All" rule for all deployed applications; entry in /etc/httpd/conf/httpd.conf:

 <Directory "/var/www/html">
     Options Indexes FollowSymLinks
     AllowOverride All 
     Order allow,deny
     Allow from all
 </Directory>
0
source

All Articles