• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.htaccess not working on Amazon EC2 [Solved]

#1
I just moved my project to EC2 and I can't get my .htaccess to work properly for removing index.php. When attempting to access my website, I receive the following error message - "The requested URL /nutrition/auth/login was not found on this server". I have tried numerous .htaccess files and switched my uri_protocol back and forth between 'REQUEST_URI' and 'AUTO'.

The folder structure of where my project is located is /var/www/html/nutrition/

I have verified that mod_rewrite is enabled. It shows as a loaded module when I view phpinfo.

I have set AllowOverride All in httpd.conf:

Code:
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride All
    Require all denied
</Directory>

Code:
#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>

base_url in config.php is set to:
PHP Code:
$config['base_url'] = 'http://<ip_address>/nutrition/'

index_page in config.php is set to:
PHP Code:
$config['index_page'] = ''

uri_protocol in config.php is set to:
PHP Code:
$config['uri_protocol'] = 'REQUEST_URI'

.htaccess file is:
Code:
RewriteEngine On
RewriteBase /nutrition/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

I know this is a common question that I'm sure you're tired of answering, but I have tried numerous offered solutions to no avail. Thanks for any help you all can give.
Reply

#2
Unless your /nutrition/ directory is document root, I'd guess you just need to change your RewriteBase to /
Reply

#3
(09-20-2017, 11:42 PM)skunkbad Wrote: Unless your /nutrition/ directory is document root, I'd guess you just need to change your RewriteBase to /

Thanks for the reply. DocumentRoot is /var/www/html. Still get the same result after setting RewriteBase to /.
Reply

#4
I have resolved the issue. Dumb mistake. There was a 3rd option to set AllowOverride All in httpd.conf. Once I set it in the code below, it worked.


Code:
# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.