Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14346

Codeigniter URI issue…No URI present. Default controller set

$
0
0
Hello,
I have an issue with my codeigniter application deployed on an EC2 instance on Amazon.

PHP Code:
    $config['base_url'] = 'http://XX.XX.XXX.107/';
    $config['index_page'] = 'index.php'


This is my route.php (without any particular rule)

PHP Code:
    $route['default_controller'] = 'home';
    $route['404_override'] = '';
    $route['translate_uri_dashes'] = FALSE


Actually if I call http://xx.xx.xxx.107/ it correctly show my first page (it loads my default controller Home.php and shows home.php view).
But if I call for example http://xx.xx.xxx.107/index.php/Test/simplepage, instead of showing simple page view, it shows again default home view.

I enabled log, and this is what I get going to http://xx.xx.xxx.107/index.php/Test/simplepage


Code:
INFO - 2016-08-08 17:27:50 --> Config Class Initialized
INFO - 2016-08-08 17:27:50 --> Hooks Class Initialized
DEBUG - 2016-08-08 17:27:50 --> UTF-8 Support Enabled
INFO - 2016-08-08 17:27:50 --> Utf8 Class Initialized
INFO - 2016-08-08 17:27:50 --> URI Class Initialized
DEBUG - 2016-08-08 17:27:50 --> No URI present. Default controller set.
INFO - 2016-08-08 17:27:50 --> Router Class Initialized
INFO - 2016-08-08 17:27:50 --> Output Class Initialized
INFO - 2016-08-08 17:27:50 --> Security Class Initialized
DEBUG - 2016-08-08 17:27:50 --> Global POST, GET and COOKIE data sanitized
INFO - 2016-08-08 17:27:50 --> Input Class Initialized
INFO - 2016-08-08 17:27:50 --> Language Class Initialized
INFO - 2016-08-08 17:27:50 --> Loader Class Initialized
INFO - 2016-08-08 17:27:50 --> Helper loaded: file_helper
INFO - 2016-08-08 17:27:50 --> Helper loaded: form_helper
INFO - 2016-08-08 17:27:50 --> Helper loaded: url_helper
INFO - 2016-08-08 17:27:50 --> Database Driver Class Initialized
INFO - 2016-08-08 17:27:50 --> Database Driver Class Initialized
INFO - 2016-08-08 17:27:50 --> Session: Class initialized using 'files' driver.
INFO - 2016-08-08 17:27:50 --> XML-RPC Class Initialized
INFO - 2016-08-08 17:27:50 --> Controller Class Initialized
INFO - 2016-08-08 17:27:50 --> Model Class Initialized
INFO - 2016-08-08 17:27:50 --> Model Class Initialized
INFO - 2016-08-08 17:27:50 --> Model Class Initialized
INFO - 2016-08-08 17:27:50 --> Model Class Initialized
INFO - 2016-08-08 17:27:50 --> Form Validation Class Initialized
DEBUG - 2016-08-08 17:27:50 --> Session class already loaded. Second attempt ignored.
INFO - 2016-08-08 17:27:50 --> File loaded: /var/www/core_ci/application/views/header.php
INFO - 2016-08-08 17:27:50 --> File loaded: /var/www/core_ci/application/views/home.php
INFO - 2016-08-08 17:27:50 --> File loaded: /var/www/core_ci/application/views/footer.php
INFO - 2016-08-08 17:27:50 --> Final output sent to browser
DEBUG - 2016-08-08 17:27:50 --> Total execution time: 0.0225


As you can see in the log, I'm getting DEBUG - 2016-08-08 15:43:25 --> No URI present. Default controller set., even if I'm calling this url http://xx.xx.xxx.107/index.php/Test/simplepage 

Here some data about my server:

    PHP Version 5.5.35
    System Linux ip-xx-x-x-xxx 4.4.8-20.46.amzn1.x86_64 #1 SMP Wed Apr 27 19:28:52 UTC 2016 x86_64
    Build Date May 2 2016 23:29:10
    Server API FPM/FastCGI

Here the vhost Apache file:


Code:
    <VirtualHost *:80>
    
      # Leave this alone. This setting tells Apache that
      # this vhost should be used as the default if nothing
      # more appropriate is available.
    
      ServerName default:80
    
      # REQUIRED. Set this to the directory you want to use for
      # your “default” site files.
    
      DocumentRoot /var/www/html
    
      # Optional. Uncomment this and set it to your admin email
      # address, if you have one. If there is a server error,
      # this is the address that Apache will show to users.
    
      #ServerAdmin you@example.com
    
      # Optional. Uncomment this if you want to specify
      # a different error log file than the default. You will
      # need to create the error file first.
    
      #ErrorLog /var/www/vhosts/logs/error_log
    
      <Directory /var/www/html>
        AllowOverride All
      </Directory>
    
      ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
      DirectoryIndex /index.php index.php
    </VirtualHost>

This is the test controller I built to investigate


PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class 
Test extends CI_Controller {
        public function __construct()
        {
                parent::__construct();
                $this->load->helper('url');
        }

        public function simplepage()
        {
                $data['title'] = 'HOME';
                $data['uriok'] = $this->uri->uri_string();

                $this->load->view('test',$data);
        }



Here the view file

Code:
<html lang="en">
<head>
    <title id='Description'>This is a simple test page.</title>
</head>
<body class='default'>
<div id='jqx'>
    <div style="margin top: 10px;"><?php echo($title) ?></div>
    <div style="margin-top: 10px;"><?php echo($uriok) ?></div>
</div>
</body>
</html>


If I execute it on my localhost it works, showing me this html page

Code:
<html lang="en">
<head>
    <title id='Description'>This is a simple test page.</title>
</head>
<body class='default'>
<div id='jqx'>
    <div style="margin top: 10px;">HOME</div>
    <div style="margin-top: 10px;">Test/simplepage</div>
</div>
</body>
</html>


if I try to run it on EC2 it fails as I already said... it execute again the default controller and show default view. It seems that as it was not able to get URI correctly, it runs default controller.
I think there is something wrong in my configuration but I was not able to find where.

Is there anyone that can tell me where I'm failing?

Thanks in advance.

Viewing all articles
Browse latest Browse all 14346

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>