Codeigniter isn't routing right
It's possible that your routes aren't resolving correctly, but I'm not sure. I'd recommend the following steps.
First, I would just do away with using PATH_INFO
for your CodeIgniter routing, as it's not necessary. Change your .htaccess
file to this:
RewriteEngine OnRewriteCond $0 !^(index\.php|images|captcha|css|js|robots\.txt)RewriteRule ^.*$ index.php [L]
Then, in your configuration, make sure that $config['uri_protocol']
is set to AUTO
(the default, I believe) or REQUEST_URI
.
Following that, the most likely cause is that your routes expect there to be a trailing slash on the URL. I don't know enough about CodeIgniter to know where that particular setting is configured, but you can cause your URLs to have a trailing slash with the following configuration directive:
$config['url_suffix'] = "/";
Edit: Make sure that mod_rewrite
is working, as well. Try this at the top of your .htaccess
file, after the RewriteEngine
directive:
RewriteRule .* http://stackoverflow.com/ [L,R]
If you get redirected to Stack Overflow, at least we'll know that's working. If not, you aren't getting a 500 error, so the problem would lie with the .htaccess
file, and in that case you should confirm that the corresponding <Directory>
entry in your server configuration for where your site is located on disk has AllowOverride All
set.
Edit: I should have known better about the forward slash, sorry about that. The problem occurs because of how mod_rewrite
works in your per-directory (.htaccess
) context.
Once your URL is rewritten, it is examined to determine what mod_rewrite
should do with it. When your URL points to a local resource and contains a leading slash, mod_rewrite
leaves it as-is. When it does not, it adds the per-directory prefix.
When it's left as-is, an internal redirect to /index.php
, in this case, is assumed to be a fully-qualified URL from the host (localhost). So, the resource requested ends up being http://localhost/index.php
. When the per-directory prefix is added, a later step in the rewrite engine attempts to remove the DocumentRoot
from the path, if it's present. This leaves us with /kids/index.php
, which is then passed to the internal redirect, and is resolved as expected.
Try this:
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^.*$ - [NC,L]RewriteRule ^(.*)$ /index.php/$1 [NC,L]
Put this in the kids folder where index.php is.