jani
jani

Reputation: 45

Config codeigniter on remote server (404 not found)

I'm starting to implement a php application on remote server using codeigniter and netbeans. I don't understand why I still have (404 not found) even if I did all the configuration. The connection to the server is OK, I can upload the files. In $config['base_url'], I tried the adress of server, the path to index.html, nothing... with no results. I actually don't know where is the problem and which file I must change, If someone can help me please to find a solution.

Thank's a lot for yous answers!

Upvotes: 0

Views: 1041

Answers (3)

notStan
notStan

Reputation: 336

You say "the path to index.html". This is not how CI works. You shouldn't access views directly. Try accessing them using your Controllers. For example you can have a controller 'Welcome' (which is the standard controller when you download the framework). It can look something like this:

<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
    function index()
    {
         $this->load->view('welcome_message');
    }
}

This controller should be located in application/controllers and it will load a view in application/views. In this case this will load 'application/views/welcome_message.php'. You can define the url for the controller in application/config/routes.php. By default the controller 'Welcome' is called when you just download the framework. Also you talk about the .htaccess file. You can use an htaccess file if you want to remove index.php? from the url. See an answer to this question here: CodeIgniter removing index.php from url

I really recommend to watch some CI basics tutorials before kicking off with the framework. You can get a grasp of how the framework and its folder structure works within a few hours.

**Edit **
Perhaps the problem isn't with codeigniter but with your webserver, you can remove your codeingiter installation and add a phpinfo file. This way you can see which php settings your server has (if php is enabled at all). Also note that nginx doesn't work with .htaccess, do if you're using an nginx server you should add a rewrite rule in your config file.

Upvotes: 1

Sello Lekgothoane
Sello Lekgothoane

Reputation: 86

Some hosting providers have Mod_Rewrite disabled by default. use phpinfo() to check if it's enabled.

Upvotes: 0

Stanley
Stanley

Reputation: 46

It is kinda hard to troubleshoot your question without seeing your configuration. I would say to first double-check that your $config['base_url'] like you mentioned, but set it to whatever the site name/address is. For example, if I am just running something locally on port 8888, it would look like this

$config['base_url'] = 'http://localhost:8888/';

So if your site was something like wwww.example.com it would be

$config['base_url'] = 'http://www.example.com/';

Also double-check your .htaccess file to re-write access if you want to remove 'index.php' from the URL. What web server are you using for your site?

Upvotes: 1

Related Questions