• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Following tutorial and getting a 404 when accessing controllers

#1
I'm following the tutorial and got as far as the controllers section.  Accessing http://localhost/codeIgniter/index.php/blog works but accessing http://localhost/codeIgniter/index.php/blog/comments does not. It throws a 404 error.

I've got base_url set as so: $config['base_url'] = 'http://localhost/codeIgniter';

I've tried adding this to my .htaccess in the /www/codeIgniter directory (as well as a couple variations I found while googling):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Mod rewrite is installed.

I've got AllowOverride All in my httpd.conf file.

I also set the index_page as blank.

I've also just tried not rewriting anything.

I'm running on WAMP on Windows 7 with Apache 2.435, and have tried PHP 5.6 and 7.

Have been at this for a couple hours now, please help?

TIA
Reply

#2
Can you enable the debug log in application\config\config.php.
And you will find them in application\logs

Can you print screen the 404 message? So we can see if it's Codeigniter or your webbserver that gives you that message.
Reply

#3
Try adding a trailing slash to the base_url string.
Reply

#4
I have had what I think is the same problem when following the tutorial. The problem is that when the function site_url() is used to get the first part of a link, it does correctly get "localhost/index.php" and adding "/news/create" (for example) completes the link. And as stated in the initial question, following that link gets a 404 error.

I played around a bit, and found that while in the source, a the link will indeed show "localhost/index.php/news/create", but hovering over the link in the browser shows that the server (apache in my case) expects to go to  "localhost/index.php/localhost/index.php/news/create". And indeed the 404 page does say it can't find that page.

I haven't quite worked out if adjustments need to be made in the web server configs of codeigniter. If some one could give a hint that would be good.

Further info that maybe helpful. I got things going by not using the site_url function, instead giving an absolute reference. So for the example I give my href is "/index.php/news/create". Works every time.

My setup is straight out of the box, with

$config['base_url'] = 'localhost/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';

Hopes this helps. And any suggestions about why things actually work for me wuld be greatly appreciated.
Reply

#5
Some time you need to change:

From this:
PHP Code:
RewriteRule ^(.*)$ index.php/$[L

To this:
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.