views:

109

answers:

5

I have a .htaccess file to remove the index.php part of the codeigniter-style URL. It's been working fine on one computer but when I copied the file over to my laptop it doesn't seem to do anything. I'm using localhost on both machines. They both run mac osx 10.6 with the bundled apache and php and the latest version of mysql. Everything works fine, it's just the .htaccess that doesn't do what it should. Is there any setting that I might have changed on my first machine and forgotten about?!

EDIT: I'm wondering if there is something wrong with my CI setup now. If I load the base_url ie http://localhost/~User/project/ then it loads perfectly, adding the index.php. My config file has

 $config['index_page'] =  '';

However, 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

Does this suggest anything to anybody?

+2  A: 

With just a shot in the dark do you have mod_rewrite installed on both?

cbattlegear
Just checked the httpd.conf file and mod_rewrite is definitely installed.
musoNic80
A: 

maybe you changed the path relative to the server root. it can breaks .htaccess and may be solved with a RewriteBase /path/to/folder/ statement


edit

since the problem not seems to be this one above, you could also check the error.log file in the apache folder (probably in the logs folder). it may have your answers and it can tell you if the .htaccess is getting parsed wrong or not parsed at all.

hugo_leonardo
It already includes a RewriteBase statement that is correct as far as I can tell.
musoNic80
there's nothing in the error log about the .htaccess file at all. Does that suggest it's not being parsed at all?
musoNic80
i gess so. or at leas it is being parsed but producing an undesired effect. since you said the .htaccess was already working before, i guess it is really not being parsed.
hugo_leonardo
A: 

If your on Ubuntu, you need to edit /etc/apache2/sites-available/default.

sudo vim /etc/apache2/sites-available/default

Where you see lines that say AllowOverride change it to say:

AllowOverride All

You may also need to enable mod rewrite:

sudo a2enmod rewrite

Then, restart the Apache server

sudo /etc/init.d/apache2 restart
Mitchell McKenna
He specifically said that he was using Mac OSX.
KyleFarris
@KyleFarris: However, he may still be correct about the `AllowOverride`.
R. Bemrose
AllowOverride is set to All
musoNic80
@KyleFarris I don't use mac, but had came across a similar situation, was hoping it would help.
Mitchell McKenna
I completely agree. I meant to state that it should be helpful, nonetheless, in helping to figure out the solution to the rewrite issue.
KyleFarris
A: 

Are you sure you have changed the name of the root folder? Here is what I do:

I put this on my root folder:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /rootFolder/index.php/$1 [L]

and in the path you replace "rootFoldel" with the name you are using.

hope that helps!

rabidmachine9
+1  A: 

SOLVED:

I added a new directory command to my httpd.conf file which targeted the specific site I was working on. Seems to be happy now, but not a very satisfactory way of dealing with the problem if I have several codeigniter sites in my web root.

musoNic80
If this really is the solution, please mark your answer as the correct or "chosen" one.
KyleFarris