.htaccess not working
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/con开发者_开发技巧troller/method
Does this suggest anything to anybody?
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.
With just a shot in the dark do you have mod_rewrite installed on both?
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
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!
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.
精彩评论