Welcome Guest, Not a member yet? Register   Sign In
CI 404 Error - Not Apache
#1

[eluser]Unknown[/eluser]
Newbie to CI. Trying to load a simple test controller. Which is just the welcome page under the name of test

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller {

/**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *   http://example.com/index.php/welcome
  * - or -  
  *   http://example.com/index.php/welcome/index
  * - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
public function index()
{
  $this->load->view('welcome_message');
}
}
I was getting 500 errors however have solved that with this .htaccess file.

Code:
# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php

# Rewrite engine
RewriteEngine On

# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

I was also having an issue with the mktime (because I am auto loading the session helper) function however have also solved that by setting the date.timezon correctly in the php.ini file.
#2

[eluser]TheFuzzy0ne[/eluser]
Have you renamed the file to? It should be test.php, not welcome.php.

What's the URL you're using to access the page when it gives you a 404 error?
#3

[eluser]Unknown[/eluser]
[quote author="TheFuzzy0ne" date="1364815453"]Have you renamed the file to? It should be test.php, not welcome.php.

What's the URL you're using to access the page when it gives you a 404 error?[/quote]

Yes I have renamed the file.

Code:
http://localhost/OceanRise/index.php/index.php/test

It gives the 404 error if I try to access any page other than the welcome page on at
Code:
http://localhost/OceanRise/index.php/index.php
#4

[eluser]TheFuzzy0ne[/eluser]
You will need to set your index page to an empty string in ./application/config/config.php

Code:
$config['index_page'] = '';

I'm not sure why index.php is in your URL twice, though. You might need to change this line in your .htaccess file from:

Code:
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

to:
Code:
RewriteRule ^(.*)$ ./index.php/$1 [L,NC]
[




Theme © iAndrew 2016 - Forum software by © MyBB