0

I have finished a project and it works fine with my local server however when I put it on a live server, it gives me 404 Not Found - 404.html when I tried to access other pages. Only index.php is working the rest is not. I am using codeigniter 2.2.0. To check if there's a problem with my code I uploaded default codeigniter. I have only two pages welcome.php and one.php. Here's the live url, http://www.fhi365.com/

here is my config file.

$config['base_url'] = 'http://www.fhi365.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

Here is my constant

define('BASEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/index.php/');

here is my route

$route['default_controller'] = "welcome";
$route['404_override'] = '';

Here is my controller

public function index()
    {
        $this->load->view('welcome_message');
    }

    public function one(){
        $this->load->view('one_view');
    }

I did not touch .htacces.

Can somebody help me.

Thanks.

Rodge
  • 61
  • 3
  • 15
  • Did you check this http://stackoverflow.com/questions/18166496/routes-in-codeigniter-404-page-not-found – Asik Nov 15 '14 at 10:22
  • Thanks, I checked the problem and it's different. My routes are working fine on local server. I don't know exactly whats the main problem on a live server. This is my my live url. http://www.fhi365.com/ if you click the link it f=gives me 404, and thats my main problem. – Rodge Nov 15 '14 at 10:35
  • This link works for you `http://www.fhi365.com/index.php?/welcome/one` This is for shared server(not all shared server) and I faced this problem at godaddy server.Try to make the link `index.php?...` you can make it lots of way. – Shaiful Islam Nov 15 '14 at 16:26
  • thanks @Shaiful Islam. This solved my problem. Is there any other alternative aside from putting "?" to index.php? – Rodge Nov 17 '14 at 01:46

2 Answers2

0

You should trust codeigniter base_url() OR site_url() . They always return the right url.

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

You must pay attention to .htaccess. If is enable

if ROOT

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

If SUBFOLDER

RewriteEngine on
RewriteBase /directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
Florin
  • 5,781
  • 2
  • 20
  • 30
  • Thanks for your advice. I did what you've said but it didn't work. I think that it's a server problem, what I did is that I add "?" to /ndex.php?/ to my constant (From @Shaiful Islam idea). However I am still searching for other alternatives aside from this. – Rodge Nov 17 '14 at 01:51
0

This is how the problem was solved.

@Florin said to trust codeigniter.

So this is my config

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

@Shaiful Islam said that I need to put "?" to index.php on my constant.

This is my constants

define('BASEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/index.php?/');

Wew! This works fine for me.

Rodge
  • 61
  • 3
  • 15