codeigniter moving from localhost to server - php

getting 404 error
404 Page Not Found
The page you requested was not found.
config.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['base_url'] = 'http://myhost/sitedir';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
default controlerr
class MY extends CI_Controller{
function __construct(){
parent::__construct();
// language
if($this->input->post("lang")){
$this->load->model("language");
$this->language->lang($this->input->post("lang"));
}
// !language
//$this->lang->load("ge");
if (!$this->session->userdata('lang'))
$this->lang->load("ge");
else
$this->lang->load($this->session->userdata('lang'));
}
/**
* mtavari gverdis controleri
*/
function index(){
$this->load->model("dbs");
$data['products'] = $this->dbs->get_products_by_limit("products",7);
$this->load->view("header");
$this->load->view("index_page",$data);
$this->load->view("footer");
}
}
uploaded default ci package in other directory and it working
i don't have a .htaccess file
sorry for my bad english :(
help me :(

Edit this line as per your server address
$config['base_url'] = 'http://server_addr/sitedir';-->like this

itś Ok. My english i'ts bad too.
If you don't use .httaccess , the URL for you website must be:
'http://website/sitedir/index.php/my'
in the defualt package you can use :
; because del defaul, `
config['index_page'] = '';
, if i don't forget it was set to "welcome".
My web site is in codeignite too, and i had this problems too reference at my incial page.
Your Configuration .php is the same as the my. But i use a . httaccess, to clear the index.php URL.
i hope help a little .

Your problem is in routing or HTACCESS Set the variable empty as below.
$config['index_page'] = '';
try to replace following variable with these parameters ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') one by one
$config['uri_protocol'] = 'AUTO';

I had this problem for the longest.. In my case, after messsing with the config file, routes, htaccess, etc... In the end the problem was that my CPANEL server was hosted through Linux and linux is case sensitive when it comes to file names. All my controllers had a capital letter for the first letter of the file name. When I changed this to lower case, it worked fine. Maybe this is your issue as well. Good luck to all.

Related

not getting proper base_url in codeigniter app

i am getting this type of url when trying to access pages other than index page
http://localhost:8012/health-care/8012//localhost/health-care/index.php/index.php/home
but url to access page must be
http://localhost:8012/health-care/index.php/home
my problem in url is: "it is duplicating url after "i hhttp://localhost:8012/healthcare/ that should not be duplicated.
i have autoloaded url helper in autoload.php as well as manually in constructor of controller. my base_url in conf
$config['base_url'] = 'http//localhost:8012/health-care/index.php/';
Guide me about this problem.
in addition to tell you that i have two app fron one codeigniter i.e. frontend and backend.
Url for backend works properly but for frontend its giving me mistakes what to do ?
$config['base_url'] = 'http//localhost:8012/health-care/';
used this base url you getting this url
http://localhost:8012/health-care/index.php/home
Y0u have to change this line
http://localhost:8012/health-care/index.php/home
to this
$config['base_url'] = 'http//localhost:8012/health-care/';
Please have a try.
Try this code:
$config['base_url'] = 'http://localhost:8012/health-care/';
and also make index_page as empty like this:
$config['index_page'] = '';
.htaccess file was not working. just replaced file and my problem got solved.

CodeIgniter doesn't load default controller on '/'

I'm using CodeIgniter with Nginx.
I have just upgraded from CodeIgniter 2.2.6 to 3.1.4, following all the changelogs and upgrade instruction. Everything works perfectly but the default controller, i.e. http://francescoruvolo.it (or even http://francescoruvolo.it/index.php) shows a 404 page but all other routing rules works and I'm able to load the other controllers.
Here is my routes.php:
$route['(it|en)/contact/check_form'] = "Email/validate_form/$1";
$route['(it|en)/contact'] = "Email/show_form/$1";
$route['(it|en)/(:any)'] = "Pages/show/$1/$2";
$route['(it|en)'] = "Pages/show/$1";
$route['default_controller'] = "Pages/show/";
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I have also tried to comment all routes, but still the default one is ignored. Still, if I go http://francescoruvolo.it/Pages/show or either http://francescoruvolo.it/en, controllers are loaded just fine and it works. Many people had similar problems because they missed the part about enforcing the capitalized name for classes, but this is not the case as my controllers' name have been already fixed.
These are the parameters in config.php:
$config['base_url'] = 'http://francescoruvolo.it/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
And Nginx looks like it is properly forwarding all requests to index.php, in fact I don't need to specify it when loading controllers explicitly. Anyway, these lines are part of my Nginx configuration for the host:
location / {
try_files $uri $uri/ /index.php;
}
What I don't get is that I'm actually able to get two different kind of 404 pages. For example, if I go to http://francescoruvolo.it/nonexistent.php Nginx correctly serves me a 404 page. At the same time, if I do not specify any path or explicitly specify index.php I get a 404 "well formatted", which means that the index.php from CodeIgniter has been actually run, but it failed to load the controller.
What am I missing? What else can I check?
Solved. Apparently, I had an extra (unneeded) / at the end of my default route.
This was WRONG:
$route['default_controller'] = "Pages/show/";
This is CORRECT:
$route['default_controller'] = "Pages/show";
Still, I don't quite get why. In fact, if I explicitly load the controller, it works even with the extra slash.
If anyone explains this, I'll gladly accept his answer. :)

Menu redirects only go to the index.php page with codeigniter

Codeigniter is a first for me so I hope I am clear in my explanation. In this case, I am dealing with setting up a Codeigniter website on a different server. I was getting forbidden access errors but have since corrected this, I think.
I've worked out the base url in config file to:
$config['base_url'] = 'http://websitename.com/';
and index_page is:
$config['index_page'] = '';
with the uri as:
$config['uri_protocol'] = 'AUTO';
The links from the menu are not redirecting properly. They simply reload the index page. In Firebug, this is what I see as one of the page links:
https://websitename.com/index.php?module/rekap_tl
Perhaps this is enough to understand the trouble here. I am working with this on a live server.
Any and all help is greatly appreciated.
you can configure codeigniter like
$config['base_url'] = ''; // Leave it empty so that codeigniter can guess it by itself, set $config['index_page'] = 'index.php'; and $config['uri_protocol'] = 'AUTO'; after that open application/config/autoload.php and then add url helper class to autoload helper $autoload['helper'] = array('url'); after that you can use in you menus "<?php echo base_url(); ?>index.php/controller/method/args" hope this may help

home.php not being accessed in codeigniter

I have a few sites set up on CI but latest one isn’t cooperating: browsing the domain doesn’t trigger home.php. I get “No input file specified”. I must be missing? (btw, when I put a test index.php file in root the echo code does render)
Here's what I've got set up -
//permissions:
//all subdirectories & file set to 755
//config.php:
$config[‘base_url’] = ‘http://example.com’;
$config[‘index_page’] = ‘home’;
//htaccess in root:
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
//routes.php:
$route[‘default_controller’] = “home”;
$route[‘404_override’] = ‘’;
//home.php:
class Home extends CI_Controller {
public function index()
{
$this->load->library('session');
$this->load->view('main_view');
}
}
My settings seem to mirror those of my other the working CI sites but I’m definitely missing something. Would appreciate feedback on what else I should look for. Thanks
Since you're removing index.php from your URI, you don't need to specify an index_page in config.php. Setting $config['index_page'] = ''; should solve your problem. You should be fine leaving your $route['default_controller'] as it is, since CodeIgniter automatically defaults to the index method.
Your 'default_controller' config must be 'home/index'
Also be sure you placed the default config on the bottom of the file. In the CI routes files, always start from the most specific to the most general ...

default_controller (in routes.php) not working in production

Regarding codeigniter routes.php :
We have following entry in C:\wamp\www\application\config\routes.php
$route['default_controller'] = 'latestC';
$route['404_override'] = 'latestC';
and latestC is our default controller. Here default_controller is not working in production. If we remove line $route['404_override'] = 'latestC'; from routes.php, we are not able to reach to home page while hitting main url mozvo.com and its a 404. Basically 404_override is doing job for us instead of default_controller for taking to homepage on hitting mozvo.com. Requests are routing to home page by 404_override controller.
But in localhost, it works perfectly. In localhost if we remove 404_controller, default_controller takes care of main url (mozvo.com, here localhost ) and others non supported urls are 404 which is correct. But in production default_controller is not taking to homepage(mozvo.com) properly so we are forced to use 404_override to take default request to homepage.
Additional Info - Entries in C:\wamp\www\application\config\config.php
$config['base_url'] = 'http://mozvo.com/';
$config['index_page'] = '';
I bet you the issue is due to case-sensitivity on files. Your local host is on WAMP - which windows does does not care about file cases.
i.e. latestC.php = latestc.php = LASTESTC.php
but on your production server (which I'm guessing is a LAMP) - case sensitivity DOES matter
i.e. latestC.php != latestc.php != LASTESTC.php
All your controllers must be LOWERCASE for Codeigniter. So change your routes to
$route['default_controller'] = 'latestc'; // all lowercase
$route['404_override'] = 'latestc'; //all lowercase
and make sure all your files are all lowercase

Categories