0
votes

I am working on codeigniter 3.1.8. It works fine on my localhost. However, when I push it to FTP server, I can only access the the default controller page. When I tried to access other view that has other controller, it gives me error '404 Not Found'

config :

$config['base_url'] = 'https://*****.net/my_project/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['enable_hooks'] = FALSE;
$config['encryption_key'] = 'xRUqKhsoZ5qV6y3kqARFJFdPqJvp7X2z';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

route :

$route['default_controller'] = 'main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

I have tried several .htaccess:

<IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /materials-library/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
      ErrorDocument 404 /index.php
</IfModule>

and

<IfModule mod_rewrite.c>

RewriteEngine On

# Set the rewritebase to your CI installation folder
RewriteBase /sandbox/ci/


# Send everything to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule> 

Any help will be very appreciated. Thanks!

3
can i send runnable ci structure ??? i think problem is in your structure.. - user8477089
I don't think so. Because I try it with CodeIgniter template, by creating one other simple controller and view. It still have the sampe problem. - Bernando Purba
put this .htaccess file into your system folder as bellow <IfModule authz_core_module> Require all denied </IfModule> <IfModule !authz_core_module> Deny from all </IfModule> - user8477089

3 Answers

0
votes

Try this, it's working for me. Make sure The file must be called ‘Yourcontroller.php’, with a capital ‘Y’.

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Make sure you have loaded uri library (application/config/autoload.php)

$autoload['helper'] = array('url', 'file');

Check out controller naming convention here:https://www.codeigniter.com/userguide3/general/controllers.html. Hope this will help you.

Greeting!

0
votes

it's normal problem and For fixed it you have to define .htaccess file in you folder. as bellow both file in your folder. put this file in your main folder and assign name Of .htaccess

RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

put this file in your application folder and assign name Of .htaccess

<IfModule authz_core_module>
  Require all denied
</IfModule>
<IfModule !authz_core_module>
  Deny from all
</IfModule>
0
votes
1) first controller name and class name first character capital letter
   example :: CapturistaCtrl
2) go to config changes ::
   -> $config['index_page'] = 'index.php'; remove index.php
   -> $config['uri_protocol']   = 'REQUEST_URI'; remove (REQUEST_URI)
3) .htaccess
   <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteCond $1 !^(index\.php|resources|robots\.txt)
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
   </IfModule>

set .htaccess file 

List item