问题
I just bought a Mac-pro with Mavericks 10.9.1 and before that I was working on pc with Windows 7.
I created a project under the windows 7 OS and now I want to import it to OSX, the import was successful apart from the .htaccess file. I can't remove index.php
from my urls.
I have MAMP installed and my urls only work if I use index.php
:
- don't work :
(localhost/~username/feel/products)
- work :
(localhost/~username/feel/index.php/products)
I tried all the options of RewriteEngine, RewriteCond and RewriteRule in .htaccess file.
I give all the folders/files chmod 755, have put $config['base_url']=''
and $config['index_page'] = '';
with and without root or index.php page.
The file .htaccess is in the same folder of the index.php page, the AllowOverride None is AllowOverride All.
回答1:
I think the problem is related to the way OS X handles different users for apache. I used the .htaccess file as described in the CodeIgniter URL documentation and added a line using RewriteBase.
RewriteEngine on
RewriteBase /~username/path/to/CI/
RewriteCond $1 !^(index\.php|static|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
By the way, I'm using OS X 10.9.3 (Mavericks) and CodeIgniter 2.2.0
回答2:
You have to set AllowOverride All
in the Directory
:
/private/etc/apache2/httpd.conf
182 <Directory />
183 Options +FollowSymLinks
184 AllowOverride All
185 Order deny,allow
186 Deny from all
187 </Directory>
then restart Apache
sudo apachectl restart
来源:https://stackoverflow.com/questions/21888077/cannot-remove-index-php-from-urls-using-codeigniter-on-mac-osx