CodeIgniter Forums

Full Version: routing doesn't work, shows 404 error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]netrox[/eluser]
I installed Apache for Windows. I bought CodeIgniter Professional and downloaded their source code. It said that I should put its .htaccess in the root folder of the website so I did. I set base URL to be http://127.0.0.1/kids/ where kids is the root folder of the website. It showed the homepage just fine. When I clicked on a link, it always gives the 404 error. It said, "The requested URL /index.php/welcome/cat/2 was not found on this server." I tried several possiblities of .htaccess in directories with no success. Inside the .htaccess, it instructs:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Explain why it's not working at all? I also checked configs.php and it seems ok as well. config['index_page'] is set to blank. I removed the .htaccess file and still same problem except that it said, "The requested URL /kids/welcome/cat/2 was not found on this server."

Two days have been wasted on trying to get it working and I am losing patience.

El Forum

[eluser]boony[/eluser]
Hi,

I take it that you mean you bought the book CI Professional? If so you may need to check that you have loaded the URL helper

Code:
$this->load->helper('url');
in your main controller because at first glance this does look like routing problem and not a .htaccess problem.

Otherwise you may need to post your controller methods so it is possible to detect if there is some other problem.

All up, check that all the config and routes files are properly set, go back and check the book source codes etc.

Boony

El Forum

[eluser]netrox[/eluser]
The problem has been solved thanks to Tim on stackoverflow.com... simply removing the initial slash in /index.php in .htaccess file solved the problem.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

has been changed to this

RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Note that the initial slash in index.php was removed. That solved the routing problem.

Problem and solution at this link:
http://stackoverflow.com/questions/34019...ting-right

El Forum

[eluser]boony[/eluser]
Er Yup,

That looks good.

Glad to see you are up and running....welcome to the world of CI