1

This is my online hosting directory structure

-- /
   -- up
   -- .logs
   -- public_html
      -- application
      -- system
      -- user_guide
      -- .htaccess
   -- DO_NOT_UPLOAD_HERE

In my config.php, I wrote this code :

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

in my .htaccess file, I have this following code :

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

I tried to remove index.php from my URL, so it will show mydomain.com/class/controller instead of mydomain.com/index.php/class/controller

It runs smoothly in my localhost, I'm using Ubuntu 15.10 with LAMPP server. However, when I tried above all code online, it shows me the 404 error page.

This is my soon-to-be-if-working-properly website : onesource.esy.es

What's wrong with my code?

Ary
  • 11
  • 2

3 Answers3

0

Your mod_rewrite rules are redirecting to /index.php instead of /codeigniter/index.php.

Put this in your .htaccess file:

RewriteBase /codeigniter/

Jonh Doe
  • 761
  • 1
  • 9
  • 25
  • Where does `codeigniter` come from? Because I don't have any folders with such name. All of my codeigniter directories stored in a folder named `public_html` – Ary Mar 17 '16 at 13:09
0

In my instances (using CI 3), I have changed the uri_protocol in the config. Try going to application/config/config.php and changing to:

$config['uri_protocol'] = 'REQUEST_URI';

Hope this helps. If not, maybe there are more suggestions here:

CodeIgniter removing index.php from url

Community
  • 1
  • 1
cfnerd
  • 3,658
  • 12
  • 32
  • 44
0

Add the following code in .htaccess file

.htaccess file must be in the root directory of your CodeIgniter Project Folder.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

In application/config/config.php file

$config['enable_query_strings'] = FALSE;

By default it is false, change it to TRUE

$config['enable_query_strings'] = TRUE;

And try again to access your controller in the browser without index.php

I hope this will work for you. (According to CodeIgniter version 3)