简体   繁体   中英

CodeIgniter htaccess issue at AWS server

This is the first time using CodeIngiter and I have url access issue. I have to include index.php in the url to access a page.

To solve the issue, I took a reference at here . I followed all steps.

I have updated at config.php as

$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

.htaccess file at root is

RewriteEngine On
RewriteCond $1 !^(index\.php | assets | images | js | css | uploads | favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

ubuntu@ip-172-31-28-229:/var/www/html/CodeIgniter$ a2enmod rewrite
Module rewrite already enabled

I can't change all AllowOverride None to AllowOverride All. in the /etc/apache2/apache2.conf file. If I do it, I even can't access my root url. My /etc/apache2/apache2.conf file is as follow.

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

I restarted my apache2 server.

But I still can't access without index.php in my url. What is still wrong?

My problem was solved using the following mod_rewrite.c

<IfModule mod_rewrite.c>
    RewriteEngine On
    Options +FollowSymlinks

    # - - - Use for 1and1 - - -
    # RewriteBase /

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Somebody who has the similar issue, pls try this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM