views:

35

answers:

3

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.

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'] = '';
A: 

Have you followed this tutorial to the letter?

treeface
Yes I have. That's exactly the .htaccess file I'm trying to use. I've even tried removing the .htaccess completely and adding the code it suggests directly into my httpd.conf file. That didn't work either.
musoNic80
After re-reading your post, I'm mostly unsure what the problem is. Are you expecting to see index.php? If not, try using this htaccess instead of the one on that page:http://snipplr.com/view/5966/codeigniter-htaccess/
treeface
@treeface I'm not expecting to see the index.php at all! Please see my update to op
musoNic80
Hey musoNic80...glad to hear you got it mostly working. What is your base_url in your config file?
treeface
At the moment it's $config['base_url'] = "http://localhost/~User/project/";
musoNic80
And can you edit your original comment to provide the exact code that replicates the problem? Also be sure to provide code examples of what does work for comparison.
treeface
Thanks for your help @treeface. Please see my update of the op.
musoNic80
A: 

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>
Yorick Peterse
A: 

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!

musoNic80