Welcome Guest, Not a member yet? Register   Sign In
Yet another CodeIgniter noob, getting nothing but 404 errors from tutorials...
#1

[eluser]dauber[/eluser]
Hi, all...I downloaded CodeIgniter and installed it actually to my web hosting account, which I believe is LAMP-based. (Surprised at how nearly-impossible it is to get the information from the provider as to what platform it is! I know it's Linux, but I don't know if it uses Apache...guessing it does.)

Anyway...everything is in my root directory. I'm just learning, so I'm following the tutorials from start to finish, and I'm already at a dead end with the static pages tutorial at http://ellislab.com/codeigniter/user-gui...pages.html.

I can get the index page to come up...but...after following the instructions in the tutorial TO THE LETTER, here's what happens...

Quote:Point your browser to [your-site-url]index.php/pages/view to see your page. When you visit index.php/pages/view/about you'll see the about page, again including the header and footer.

Uhh...nope. I get the CI 404 page.

I've properly edited the config.php file to point to the proper URL...what else should I be looking for? I've searched the forums here and looked at the wiki to no avail...

BTW, there is NO .htaccess file.
#2

[eluser]Unknown[/eluser]
Hello, this is my first post in this forum and I have a similar issue to dauber in his original post. I followed the instructions to the letter and still get an error. I suppose there are a few things that I'd like clarified on my CI setup.

* All CI folders are located at C:\Program Files (x86)\Apache2.2\htdocs\ci.
* Apache is installed locally on my windows machine and the service is running, listening to port 8080.
* In my config.php file, I have my base site url listed as: $config['base_url'] = 'http://localhost:8080/';
* Anytime I point my browser to http://localhost:8080/ci/index.php/pages/view or http://localhost:8080/index.php/pages/view I get

Not Found

The requested URL /ci/index.php/pages/view was not found on this server.

1. Is this the correct base site url or should I list the local path (C:\Program Files\..?
2. My file directory structure is correct so why is nothing displayed?

I tried to follow the thread, going to index.php/welcome and the same error occurred.

Not Found
The requested URL /ci/index.php/welcome was not found on this server.

If anyone could point me in the right direct ... no threads I have found yet could help me. =( If there is any information I could provide to help, please let me know.
#3

[eluser]Unknown[/eluser]
you will get 404 error if you put the SYSTEM and APPLICATION folder out of the www root folder.

file_exists do not know the $application_folder in your index.php.
so just comment out IF
Code:
//if(!file_exists('../application/views/pages/'.$page.'.php'))
//{
// show_404();  
//}

$data['title'] = ucfirst($page);

$this->load->view('templates/header',$data);
$this->load->view('pages/'.$page,$data);
$this->load->view('templates/footer',$data);
#4

[eluser]Unknown[/eluser]
Jixiang is exactly right.

The problem most likely is that, following the security suggestion in the same tutorial, you've moved your application and system folders outside of your webroot to another directory.

Therefore the path that's used in the file_exists() is no longer valid.

A solution, as jixiang pointed out, is to comment out the if check.

A better solution is to add the whole path to your file_exists() check, as in 'yourdirectory/application/views/pages/'.$page.'.php')
#5

[eluser]Unknown[/eluser]
I created a 'server' directory next to public_html and in case I needed to add to it, designated a codeigniter directory within containing all the codeigniter files.
Then I found adding this useful in index.php:

Code:
define("CI_ROOT", rtrim($_SERVER["DOCUMENT_ROOT"], "/public_html") . "/server/codeigniter");

then for example in Pages:

Code:
if (!file_exists(CI_ROOT . '/application/views/pages/' . $page . '.php')) {
#6

[eluser]CroNiX[/eluser]
Just use the built in APPPATH constant (defined at the bottom of index.php and is what CI uses internally), which is a full path that points to
/your/install/application/

So just
Code:
if ( ! file_exists(APPPATH . 'views/pages/' . $page . '.php')) {

No need to recreate something that is already there, and it won't matter if you've relocated the application dir.
#7

[eluser]Unknown[/eluser]
I went nuts trying to figure this out. None of the suggestions above helped.

Turns out, in the tutorial it has you create a new controller file 'pages.php'. That said, this is wrong. It needs to be 'Pages.php'. You need the first letter capitalized for it to work.

https://docs.google.com/file/d/0B1EFK2xm...p=drivesdk
#8

[eluser]InsiteFX[/eluser]
All class names begin with a capital letter the only files that are saved with the first letter capitalized are Library files.
#9

[eluser]Unknown[/eluser]
Thanks williamdeangelis! Was bugging me! Well spotted!

[quote author="williamdeangelis" date="1389313728"]I went nuts trying to figure this out. None of the suggestions above helped.

Turns out, in the tutorial it has you create a new controller file 'pages.php'. That said, this is wrong. It needs to be 'Pages.php'. You need the first letter capitalized for it to work.

https://docs.google.com/file/d/0B1EFK2xm...p=drivesdk
[/quote]
#10

[eluser]InsiteFX[/eluser]
It is not wrong!

pages.php is the filename you save it to. All class names start with an upper case letter that was your problem.

Code:
class Pages extends CI_Controller
{

}

Saved as pages.php





Theme © iAndrew 2016 - Forum software by © MyBB