1

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?

Community
  • 1
  • 1
batuman
  • 7,066
  • 26
  • 107
  • 229

1 Answers1

1

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>
halfer
  • 19,824
  • 17
  • 99
  • 186
batuman
  • 7,066
  • 26
  • 107
  • 229