I'm wondering if there is something wrong with my CI setup. If I load the base_url ie http://localhost/~User/project/ then it loads perfectly, adding the index.php before the default controller. However, my config file has
$config['index_page'] = '';
As a test I returned this value to 'index.php'. When I loaded the base_url after this it returned: http://localhost/~User/project/index.php/index.php/controller/method
Is this what I shoul expect? I'm having big problems with my .htaccess file which doesn't seem to be working. I posted this as a separate question incase the two are unrelated.开发者_StackOverflow中文版
UPDATE: I've now got the .htaccess working and the index.php has disappeared BUT ONLY IF TYPE THE FULL URL.
If I just type the base_url then it loads the default controller but still adds the index.php into the string.
To clarify...
If I type: http://localhost/~User/project/controller/method everything works as expected and the URL stays exactly like this. Similarly if I follow relative links then the correct controllers and methods are loaded with index.php appearing in the URL.
If, however, I only type: http://localhost/~User/project it redirects me to http://localhost/~User/project/index.php/controller/method
The controller is the default that I have setup in my config file and I have also set
$this->config['index_page'] = '';
Have you followed this tutorial to the letter?
Try using the following .htaccess file, it has never let me down so far:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
SOLVED:
Ok this makes me feel really stupid, but I found the cause of the problem. I had a redirect function tucked away in MY_Controller that I'd completely forgotten about. Because previously i couldn't get the .htaccess to work, I'd hard-coded the redirect to include index.php. Everything is now working as it should. Many apologies for wasting your time trying to solve a problem that didn't exist!
精彩评论