I have a little problem with codeigniter, I have a .htaccess for rewrite the index.php it works great if I put my projects on /var/www or if I make a virtual host for it.
But I want to use my user directory such as http://localhost/~userdir/myproject. If I use my user directory when I'm trying to do request to a controller like: http://localhost/~userdir/myproject/signup I get this error:
Not Found
The requested URL /index.php was not found on this server.
This is my current configuration:
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
application/config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['encryption_key'] = 'myencryption_key';
//all remaining is the default config
This config works great on http://localhost/ and also on production enviroments with a domain like http://example.com/ but not on my user directory http://localhost/~userdir/project/
What I doing wrong? Any thoughts?
Thanks in advance.
Best Answer
Well, I found a solution in codeigniter forums, first I need to add RewriteBase line as follows:
Then, remove the slash before index.php on last line.
Someone said that
is redundant, the following two lines of code cover it,
So, my final .htaccess is like this:
It works well locally with http://localhost/~userdir/myproject also on production with http://example.com/~userdir/myproject